Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scandinavian keyboard layout can't handle input tilde (~) #2151

Open
ixrock opened this issue May 31, 2019 · 52 comments · Fixed by #3430 or #3432
Open

Scandinavian keyboard layout can't handle input tilde (~) #2151

ixrock opened this issue May 31, 2019 · 52 comments · Fixed by #3430 or #3432
Labels
area/ime help wanted type/bug Something is misbehaving

Comments

@ixrock
Copy link

ixrock commented May 31, 2019

To type ~ with Finnish/Swedish keyboard I have to press hotkey alt+^:
image

After that it shows something similar to ~ but right after when I press any other character (except Enter) it will erase "pre-tilde" symbol. Press Enter "converts" to normal ~ and nothing more (without real Enter).

I checked how this works with vanilla JS and it seems something wrong at browser-level:
image

Is it fixable? Wdyt?

Related bugs:

#174

Details

  • Browser and browser version: Chrome (latest)
  • OS version: MacOS X (latest)
  • xterm.js version: 3.14.0

Steps to reproduce

  1. Add support of Finnish keyboard in your OS
  2. Try to use ~ from keyboard
@ixrock ixrock changed the title 🇫🇮Finnish keyboard can't handle tilde char (~) properly 🇫🇮Finnish keyboard can't handle tilde char (~) May 31, 2019
@Tyriar
Copy link
Member

Tyriar commented May 31, 2019

VS Code issue: microsoft/vscode#68262

@Tyriar Tyriar added the type/bug Something is misbehaving label May 31, 2019
@ixrock
Copy link
Author

ixrock commented May 31, 2019

@Tyriar how xterm related to vscode?

@Tyriar
Copy link
Member

Tyriar commented May 31, 2019

vscode uses xterm, that's the issue that's been reported over there.

@ixrock ixrock changed the title 🇫🇮Finnish keyboard can't handle tilde char (~) 🇫🇮Scandinavian keyboard layout can't handle tilde char (~) Jun 2, 2019
@ixrock ixrock changed the title 🇫🇮Scandinavian keyboard layout can't handle tilde char (~) Scandinavian keyboard layout can't handle tilde char (~) Jun 2, 2019
@ixrock ixrock changed the title Scandinavian keyboard layout can't handle tilde char (~) Scandinavian keyboard layout can't handle input tilde (~) Jun 2, 2019
@gdlx
Copy link

gdlx commented Jun 3, 2019

Terminus has the same issue: Eugeny/tabby#768
This isn't limited to Scandinavian keyboards. At least French and Spanish are affected too (any layout with the AltGr key and 2 steps accents feature I presume).

@ixrock
Copy link
Author

ixrock commented Jun 3, 2019

It's still possible to catch ~ with InputEvent:

image

@Tyriar
Copy link
Member

Tyriar commented Jun 3, 2019

I'm not sure if this ever worked if InputEvent fixes the problem, sounds like it might be the same root cause as #469 and needs us to move input handling over to input instead of the key events.

@ixrock
Copy link
Author

ixrock commented Jun 3, 2019

@Tyriar Using only InputEvent for sure not enough. Its evt.data just contains current value-string for input/textarea and nothing about pressed keys, etc. I just thought it might help to fix this issue combined with normal KeyboardEvent.

@goulartdev
Copy link

I'm having the same issue in Fluent Terminal.
I can't type ~, it shows Þ instead. My keyboard is PT-BR (with the AltGr key), but if I change the layout to US, I can type ~ using the ' key.

@insertt
Copy link

insertt commented Jul 25, 2019

Until this issue will be fixed I suggest using workaround from here

@GitSquared
Copy link

GitSquared commented Oct 4, 2019

I'm not sure if this exactly the same issue, but I find that typing any diacritics (like ö ầ etc), not just the tilde, on xterm doesn't work at all (prints like o a, without any diacritic applied). Tested with french keyboard and Linux, latest xTerm.js on Hyper and/or eDEX-UI.

@Tyriar
Copy link
Member

Tyriar commented Oct 4, 2019

@GitSquared I think this might be related to your $LANG variable?

@GitSquared
Copy link

@Tyriar My $LANG is set to en_US.UTF-8 - but typing diacritics does work in other terminal emulators (Konsole), and switching to, for instance, fr_FR.UTF-8 does not resolve the issue.

Also, I'm unsure how $LANG affects typing input? Is this some xterm.js-specific behavior?

@jerch
Copy link
Member

jerch commented Oct 7, 2019

@Tyriar Is this only an issue under Mac or with Mac keyboards (MBP)? I have no problems with PC keyboards with german keyboard layout - all third level shifts work as intented in all browsers (tested with demo in chrome + FF).

Some ideas whats going wrong (in fact it looks like 2 separate issues on the lower level):

  • original poster reported to press Alt + ^: Alt has a special meaning by default, we map it to the Meta key for PC keyboards (as it lacks a dedicated Meta key). This assumption might be wrong for some keyboard types (Mac?). For Mac keyboards we have an macOptionIsMeta setting, we might have to check if this needs a slightly different Alt+XY key handling in Keyboard.ts as well if set.
  • fluentTerminal and AltGr issue: This looks like the browser engine reports the wrong key/keyCode (not applying keyboard layout correctly?). When AltGr is held down normally the reported entry should shift to the third character for the second key, if browser do wrong here I fear there is not much we can do in the first place. But atm this is all speculation and needs proper bug testing to catch all edge cases. If InputEvent still reports the right key value we might get away with a combined KeyboardEvent + InputEvent processing. If this does not work - a last resort might be to deliver our own (customizable) keyboard layout maps.

Key handling always has been a pain in the a** in browsers, maybe we can learn something from the monaco guys here?

Things mentioned in this issue are hard to fix as long as we cannot repro it and dont know the exact circumstances this bug shows up (OS + browser version). Any volunteers to (partly) address this?

To test if the browser reports the right thing you can use https://w3c.github.io/uievents/tools/key-event-viewer.html.

@Tyriar
Copy link
Member

Tyriar commented Oct 7, 2019

Is this only an issue under Mac or with Mac keyboards (MBP)?

@jerch you might be right OP and the 2 linked vscode issues are all on macos.

@laarmen
Copy link

laarmen commented Oct 8, 2019

FYI, a string of closed/duplicate issues on the VSCode repository lead me to this issue, and I'm on Windows. Using a French AZERTY layout, the tilde is on the "number" row, on the "2" key, which has as main char "é", shift char "2" and third char "~", which normally has a dead key behaviour. Thus, to type in a ~ character, the normal sequence would be AltGr+é, Space. However, when doing so the result is é~.

I'm not entirely certain it is the exact same bug, but I'm assuming it stems from the same root causes.

@jerch
Copy link
Member

jerch commented Oct 8, 2019

@laarmen It seems we first have to identify the problematic layouts, AZERTY seems to be one of them. Our problem is that none of us can dig into that, we only use english/german keyboard layouts.

So if you dont mind - could you also check if the other third shifts are wrong as well (I assume so)? And whether https://w3c.github.io/uievents/tools/key-event-viewer.html reports the right thing - if so its prolly a problem on our side.
Please also report us your OS version and installed language / keyboard layout. (Not sure yet, I think the browser tries to apply the OS keyboard layout setting for the event codes, thus this might also be a source of trouble depending on the configuration).

Edit: Here is a list of common latin keyboard layouts https://en.wikipedia.org/wiki/List_of_Latin-script_keyboard_layouts (and links to other layouts in the footer). And the ISO spec for keyboards https://en.wikipedia.org/wiki/ISO/IEC_9995.

@laarmen
Copy link

laarmen commented Oct 8, 2019

OK, so I tried to reproduce on a Docker xterm.js instance, and couldn't reproduce (Firefox and Chrome both). I'm on Windows 10, and my bug happens in the VSCode terminal (1.38.1). 🤷‍♂

@jerch
Copy link
Member

jerch commented Oct 8, 2019

@laarmen Oh thats weird, Im pretty sure vscode runs exactly the same code for key input unaltered.

@Tyriar FYI. Maybe an electron bug not correctly applying OS keyboard layout?

@Tyriar
Copy link
Member

Tyriar commented Oct 8, 2019

@rebornix have you seen any reports around this for monaco?

@ssh-peppe
Copy link

ssh-peppe commented Jan 2, 2020

For me on macOS, Finnish keyboard, with Safari and Chrome a tilde + space results in ~ and tilde + n results in ñ as it should. But on Firefox a tilde + space results in ~~ and tilde + n results in ~ññ.

Interestingly this behavior difference can be seen (but a bit differently for some reason) on the https://xtermjs.org/ home page example terminal. If you enter tilde + space there on Safari you get nothing at all. Same for tilde + n. But with Firefox while tilde + space gets you nothing a tilde + n gets you ñ. Not sure why it's working differently there.

Debug logging shows the following when typing tilde + space on Firefox:

xterm.js: sending data "~" Array [ 126 ]
xterm.js: sending data "~" Array [ 126 ]
xterm.js: parsing data ~~

For tilde + n it shows:

xterm.js: sending data "~" Array [ 126 ]
xterm.js: sending data "ñ" Array [ 241 ]
xterm.js: sending data "ñ" Array [ 241 ]
xterm.js: parsing data ~
xterm.js: parsing data ññ

Note that there are differences in browsers with regards to what is reported from e.g. compositionend vs. input vs. keydown vs. keypress events.

I should add that nothing is being sent until you hit space or n. That is, the initial tilde that starts the character compose does not result in any callbacks firing, whch is correct.

@alexandrehpiva
Copy link

alexandrehpiva commented Jun 7, 2021

As @Tyriar set that issue as a duplicate of this one, I am posting here that nothing solves for me.

I tried to re-install VSCode, change terminal to use ZSH shell, change the VSCode language and added configuration "terminal.integrated.env.linux" to use UTF-8.

I personally don't think this is the same problem of that issue because I am using Ubuntu and when I type (in VSCode terminal) a special char alone and press space it works ex.: "^~`'", but when I type a special char like "^" + "a" only show "a" instead of "â". Same with "áâãéẽíĩóú". But in normal Ubuntu terminal everything works ok.

Does anyone have any more ideas?

@jerch
Copy link
Member

jerch commented Jun 7, 2021

@alexandrehpiva Can repro that under ubuntu with chrome and QWERTZ (german layout), where ^ is a dead key. I think dead key composition never worked correctly for chrome under linux, while it works with firefox.

Can you confirm - is ^ a dead key in your keyboard layout? (dead key - not producing a symbol on first press, instead adding some modification to a following key, often used to add ^, ~, ¨ or other accents to a letter)

@Eugeny
Copy link
Member

Eugeny commented Aug 25, 2021

@Tyriar bad news, found out that some Windows machines just don't produce the "Dead" keydown no matter what. I'm investigating and I think we should reopen this for the time being.

@Eugeny
Copy link
Member

Eugeny commented Aug 25, 2021

Looks like it's producing a bogus version of a third level shift with AltGraph instead of alt and missing modifier flags - here's the broken version:

image

and a normal third level shift:

image

@Tyriar Tyriar reopened this Aug 25, 2021
@Tyriar
Copy link
Member

Tyriar commented Aug 25, 2021

😦

@fperez
Copy link

fperez commented Sep 2, 2021

I am seeing the same problem (which also impacts JupyterLab, where we use xterm.js) and wanted to mention that there's an easy way even for developers on US keyboards to reproduce it, which may help track it down: I'm on a Mac, and if you install the "US International" layout:

image

that will give you dead keys for accents in western languages (I use it as I have to type regularly in English, Spanish and French + coding and my keyboards are US-layout). With this layout active, to type say cd ~ I will type cd , then tilde, then space. The space keystroke makes the tilde dead-key become the normal tilde (instead of say ~ + n, which will become ñ with that layout.).

As of right now, testing this on the xtermjs.org terminal with this layout does not work (nor do other accents).

I hope this helps the dev team perhaps track it down better - we'd greatly benefit from a fix to this on the JupyterLab team... LMK if I can provide further testing/feedback (no fixing offered - I don't know this codebase/JS well enough to help, sorry!!). Otherwise thanks for the fabulous tool!

@alexandrehpiva
Copy link

Can you confirm - is ^ a dead key in your keyboard layout? (dead key - not producing a symbol on first press, instead adding some modification to a following key, often used to add ^, ~, ¨ or other accents to a letter)

No, it isn't. My keyboard is pt-BR Brazilian Portuguese. Really, my problem explanation is like the
issue microsoft/vscode#105051

@fperez
Copy link

fperez commented Sep 2, 2021

@alexandrehpiva do you still get the problem on VSCode? I just tested it on my current setup (VSCode 1.59.1 on MacOS Big Sur, with US International layout) and it's now fine. Just checking to see if with current versions of VSCode it still happens, to help narrow down things.

@alexandrehpiva
Copy link

@alexandrehpiva do you still get the problem on VSCode? I just tested it on my current setup (VSCode 1.59.1 on MacOS Big Sur, with US International layout) and it's now fine. Just checking to see if with current versions of VSCode it still happens, to help narrow down things.

Yes, I just update to 1.60.0, and still same problem. I'm unable to use accented characters with Ubuntu bash inside VSCode. I tried to install and use Oh My ZSH too and still same. The mad thing is that work's perfectly in terminal outside VSCode. Anyone knows how to change configuration for this (if exists) in Ubuntu 20.04 LTS?

@alexandrehpiva
Copy link

alexandrehpiva commented Sep 3, 2021

I recorded an example:

Peek 2021-09-03 08-40

@alexandrehpiva
Copy link

alexandrehpiva commented Sep 3, 2021

I just discovered a strange thing: If I press the accent key 3 times and then press the letter, it works and I get: "~ã"

Peek 2021-09-03 08-43

@thiagobraga
Copy link

I just discovered a strange thing: If I press the accent key 3 times and then press the letter, it works and I get: "~ã"

I realized the same thing today. If I press the tilde key followed by the "a" key, it is displayed a in the terminal and not ã. But if I press the tilde three times and then the "a" key, is produced. I imagine the issue should not be closed yet. I'm on Ubuntu 20.04.3 and on Terminator and Gnome Terminal the accent works perfectly.

@devphobia
Copy link

Ubuntu 20.04 using GNOME and having the same issues.
The integrated terminal doesn't seem to allow me to input characters like [é, ó, ú, ô, etc...] while all my other terminals work just fine. Even installed Atom to see if the bug persisted on other code editors but it seems it's related to VSCode and VSCode only.
Any ideas on how to get rid of this?

@mauriciosantosds
Copy link

Same problem here with vscode integrated terminal in Ubuntu 20.04 GNOME.

@renathoaz
Copy link

For those using Ubuntu 20.04.
After a long searching I found out that vscode depends on ibus for the accents work on integrated terminal.
the workaround :

1.Install ibus: sudo apt install ibus ibus-gtk3
2. Create the config file:

cat <<EOF >ibus.dconf
[general]
preload-engines=['xkb:br::por']

[general/hotkey]
triggers=@as []

[panel]
show-icon-on-systray=false
EOF
  1. import it to dconf: dconf load /desktop/ibus/<ibus.dconf
  2. init ibus with proper config: im-config -n ibus
  3. activate ibus on GNOME: gsettings set org.gnome.desktop.input-sources sources "[('ibus', 'xkb:br::por')]"

and now everything is just working fine:

Seleção_329

@thiagobraga
Copy link

Now I'm not using Ubuntu 20.04 anymore, I upgraded to Ubuntu 21.10 and VSCode 1.66. I noticed that ibus and ibus-gtk3 are already installed. I believe that since I reinstalled, I hadn't done the accent test in VSCode terminal. And to my surprise, it now worked normally, without having to change any settings.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ime help wanted type/bug Something is misbehaving
Projects
None yet