Language independent hotkeys (#34053)
Addresses #10972 Closes #24950 Closes #24499 Adds _key_en_ to _Keystroke_ that is derived from key's scan code. This is more lightweight approach than #32529 Currently has been tested on x11 and windows. Mac code hasn't been implemented yet. Release Notes: - linux: When typing non-ASCII keys on Linux we will now also match keybindings against the QWERTY-equivalent layout. This should allow most of Zed's builtin shortcuts to work out of the box on most keyboard layouts. **Breaking change**: If you had been using `keysym` names in your keyboard shortcut file (`ctrl-cyrillic_yeru`, etc.) you should now use the QWERTY-equivalent characters instead. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
51df8a17ef
commit
f50041779d
5 changed files with 108 additions and 13 deletions
|
@ -136,17 +136,17 @@ When this happens, and both bindings are active in the current context, Zed will
|
|||
|
||||
### Non-QWERTY keyboards
|
||||
|
||||
As of Zed 0.162.0, Zed has some support for non-QWERTY keyboards on macOS. Better support for non-QWERTY keyboards on Linux is planned.
|
||||
Zed's support for non-QWERTY keyboards is still a work in progress.
|
||||
|
||||
There are roughly three categories of keyboard to consider:
|
||||
If your keyboard can type the full ASCII ranges (DVORAK, COLEMAK, etc.) then shortcuts should work as you expect.
|
||||
|
||||
Keyboards that support full ASCII (QWERTY, DVORAK, COLEMAK, etc.). On these keyboards bindings are resolved based on the character that would be generated by the key. So to type `cmd-[`, find the key labeled `[` and press it with command.
|
||||
Otherwise, read on...
|
||||
|
||||
Keyboards that are mostly non-ASCII, but support full ASCII when the command key is pressed. For example Cyrillic keyboards, Armenian, Hebrew, etc. On these keyboards bindings are resolved based on the character that would be generated by typing the key with command pressed. So to type `ctrl-a`, find the key that generates `cmd-a`. For these keyboards, keyboard shortcuts are displayed in the app using their ASCII equivalents. If the ASCII-equivalents are not printed on your keyboard, you can use the macOS keyboard viewer and holding down the `cmd` key to find things (though often the ASCII equivalents are in a QWERTY layout).
|
||||
#### macOS
|
||||
|
||||
Finally keyboards that support extended Latin alphabets (usually ISO keyboards) require the most support. For example French AZERTY, German QWERTZ, etc. On these keyboards it is often not possible to type the entire ASCII range without option. To ensure that shortcuts _can_ be typed without option, keyboard shortcuts are mapped to "key equivalents" in the same way as [macOS](). This mapping is defined per layout, and is a compromise between leaving keyboard shortcuts triggered by the same character they are defined with, keeping shortcuts in the same place as a QWERTY layout, and moving shortcuts out of the way of system shortcuts.
|
||||
On Cyrillic, Hebrew, Armenian, and other keyboards that are mostly non-ASCII; macOS automatically maps keys to the ASCII range when `cmd` is held. Zed takes this a step further and it can always match key-presses against either the ASCII layout, or the real layout regardless of modifiers, and regardless of the `use_key_equivalents` setting. For example in Thai, pressing `ctrl-ๆ` will match bindings associated with `ctrl-q` or `ctrl-ๆ`
|
||||
|
||||
For example on a German QWERTZ keyboard, the `cmd->` shortcut is moved to `cmd-:` because `cmd->` is the system window switcher and this is where that shortcut is typed on a QWERTY keyboard. `cmd-+` stays the same because + is still typeable without option, and as a result, `cmd-[` and `cmd-]` become `cmd-ö` and `cmd-ä`, moving out of the way of the `+` key.
|
||||
On keyboards that support extended Latin alphabets (French AZERTY, German QWERTZ, etc.) it is often not possible to type the entire ASCII range without `option`. This introduces an ambiguity, `option-2` produces `@`. To ensure that all the builtin keyboard shortcuts can still be typed on these keyboards we move key-bindings around. For example, shortcuts bound to `@` on QWERTY are moved to `"` on a Spanish layout. This mapping is based on the macOS system defaults and can be seen by running `dev: Open Key Context View` from the command palette.
|
||||
|
||||
If you are defining shortcuts in your personal keymap, you can opt into the key equivalent mapping by setting `use_key_equivalents` to `true` in your keymap:
|
||||
|
||||
|
@ -161,6 +161,12 @@ If you are defining shortcuts in your personal keymap, you can opt into the key
|
|||
]
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
Since v0.196.0 on Linux if the key that you type doesn't produce an ASCII character then we use the QWERTY-layout equivalent key for keyboard shortcuts. This means that many shortcuts can be typed on many layouts.
|
||||
|
||||
We do not yet move shortcuts around to ensure that all the builtin shortcuts can be typed on every layout; so if there are some ASCII characters that cannot be typed, and your keyboard layout has different ASCII characters on the same keys as would be needed to type them, you may need to add custom key bindings to make this work. We do intend to fix this at some point, and help is very much wanted!
|
||||
|
||||
## Tips and tricks
|
||||
|
||||
### Disabling a binding
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue