-
Notifications
You must be signed in to change notification settings - Fork 58
Improve support for international keyboards #144
Conversation
….code property to keystrokes
If alt- or shift-alt- produces an ASCII character on the current layout, interpret the keystroke as that character. If ctrl or cmd are also pressed, don’t use the alternative character for the binding. For example, on a Swiss layout: alt-g is interpreted as @ ctrl-alt-g is still interpreted as ctrl-alt-g
This enables cmd-d on a Greek keyboard rather than cmd-δ, which matches the behavior os OS X. Non-ASCII characters that still fall in the Latin character set are not converted, and we only apply the conversion when a modifier is depressed.
Signed-off-by: Nathan Sobo <[email protected]>
Signed-off-by: Nathan Sobo <[email protected]>
Signed-off-by: Nathan Sobo <[email protected]>
The only time that we can't use KeyboardEvent.key is on macOS when the option key is held down. In that case, the .key property will contain an alternative character. In order to match alt bindings, we need to know the character that the key would have typed if option were not held down. We determine this character using the keyboard-layout module. Signed-off-by: Nathan Sobo <[email protected]>
Signed-off-by: Nathan Sobo <[email protected]>
Signed-off-by: Max Brunsfeld <[email protected]>
Is there an easy way to "test drive" this change? Can I just download atom alpha and replace the atom-keymap with this change? |
You can download the build artifacts for a branch build of Atom with this version of the keymap from our third-party build providers: |
My Platform: Windows 10 / 64bit (not that it matters) / German Keyboard Layout I'll go over all the keys that don't work in 1.10 for me and how it compares to the new version. This is sorted by position on the keybard in english text reading direction.
Overall a VAST improvement for me. The only problem remaining is the @ / Reflow thing and that even comes with a quick remedy (undo removing only the reflow). I've used the editor for only a few minutes, but my "OMG I CAN'T TYPE THAT" reflexes are already relaxing. I used to Ctrl+F \ Ctrl+A Ctrl+C ESC Ctrl+V to get a This feels pretty native to me. I hope this holds true to all these other layouts out there! |
@ccoenen What platform are you on? I want to fix the reflow selection problem. |
Okay, so I've narrowed the reflow issue down to a menu item with Does anyone have a suggestion for a better default binding scheme on Windows? There really seems to be very little real estate. |
Signed-off-by: Max Brunsfeld <[email protected]>
Signed-off-by: Max Brunsfeld <[email protected]>
4175d49
to
fcd0eb3
Compare
This avoids calling the non-existent getModifierState method on our fake keyboard events when running on Travis.
66d97b3
to
83a451b
Compare
There's another funny side-effect that I didn't test before: On a german keyboard, there's no single key for This shortcut did not work in atom 1.10, it does work in this version. That's a very welcome surprise! (meaning this might well have fixed #34 along the way) |
Hi, I'm on Linux with a Norwegian keyboard (nb_NO) Everything works fine when writing code, but the Key Binding Resolver showes wrong keys. Problem is that some shortcuts are not working (ctrl+\ => toggle tree view). Read a lot of threads, but couldn't get to the bottom of the problem I'm willing to contribute to get this fixed, but not really sure what to do. Cheers |
@fractalf This should be fixed starting with Atom 1.12-beta. Contribution at this point would be to wait for beta and see if everything works 🎉 |
@Ben3eeE I installed the 1.12-beta0 today and the issue remains. Did I miss some setting? Scanned the settings, but couldn't find any. Weird thing though, the actual CTRL+\ gave CTRL+] earlier. Now it shows CTRL+=. |
Thanks for following up 🙇. There should not be any setting for this. Which OS are you on? In addition I can think of these questions.
/cc: @thomasjo Norsk layout. |
I see in your comment ☝️ that you are on Linux, the exact version could still help. In addition to the above questions can you please also provide the following:
|
Cheers for the follow-up, issue is not resolved, here's some more data..
Running OK, this is quite weird. In the Key Binding Resolver this is what I get:
My locale settings were a bit of, meaning they were set to Swedish (god help me), so I changed them to Norwegian, but that doesn't seem to have any impact either.
..awaiting further instructions :) EDIT 1: Oh, and yes the keyboard layout is Norwegian and all works perfectly fine when writing normally. Seems to be problems when combining with ctrl EDIT 2: I found a CLI utility named xev. This is what I get when I press
|
/cc: @nathansobo |
It looks like Chrome is misreporting the value of |
Closes #35
Now that the new
KeyboardEvent.key
andKeyboardEvent.code
APIs are available in Chrome, we can finally support international keyboard layouts in core without a building tower of fragile hacks. This isn't as straightforward as I'd hoped, but this PR updates our translation of keyboard events to keystroke strings as follows:AltGraph
handlingLinux
The keystroke's primary character is always based on the
.key
property of the keyboard event. If we determine that theAltGraph
key is depressed viaKeyboardEvent.getModifierState
, we don't renderalt
as part of the keystroke. On Windows, we also don't renderctrl
as part of the keystroke sincectrl-alt-
is commonly used as a substitute for the physicalAltGraph
key.On macOS
Like Linux, we base the primary character on the
.key
property of the keyboard event.Because Macs don't have a dedicated
AltGraph
key, we need to be more nuanced about interpreting the user's intent when they use the Mac⌥
key. If we always interpreted⌥
to meanAltGraph
, manyalt-
bindings would become impossible to type on macOS. Instead, we only consider⌥
to meanAltGraph
whenKeyboardEvent.key
is in the basic ASCII character range. If⌥
is used and the typed character is non-ASCII, we use a native node module to determine the non-⌥
-modified variant of the character based on the physical location of the key (KeyboardEvent.code
) and the current system keyboard layout.For example, on a Swiss-German layout, we will resolve
⌥G
keystrokes to@
rather thanalt-g
because@
is an ASCII symbol. However, we won't resolve⌥G
to©
on a U.S. layout because we consider the ability to bindalt-g
more important than typing copyright symbols. However, if you want to type©
with⌥G
, that will work fine as long as there are no existingalt-g
bindings. As a text editor used to write code, we considered it worthwhile to treat ASCII as a special case and protect the ability to type basic ASCII from any packages that might accidentally shadow those keystrokes withalt-
bindings.On Windows
We treat
ctrl-alt-
specially in the same way we treat⌥
specially on macOS. If actrl-alt-
keystroke produces an alternative character in the ASCII character set, we'll treat the keystroke as that character. Otherwise we'll treat it as actrl-alt-
binding.Key bindings on non-Latin layouts
If you're using a Greek keyboard on macOS,
⌘Σ
does not exist as a binding. If you type that physical key combination, it actually resolves to⌘S
, which is the default binding for saving a document.In Atom, we've tried to copy this behavior. Basically, bindings can be expressed only with Latin characters. So
alt-u
can be bound and so canalt-ü
, but on non-Latin layouts, keystrokes with modifiers convert the typed character to its equivalent on a U.S. layout.Apologies if this appears to be a culturally insensitive approach... We're trying to match the expected behavior and it seemed like macOS is a good guide in this respect. Please let us know if we're missing some nuance here.