zed
zed copied to clipboard
Linux Shortcuts don't work with non-latin / international keyboard layouts
Description
If you switch the keyboard layout to another language, the hotkeys stop working.
For example ctrl + s or ctrl + c.
Environment
Zed on Linux
Can you provide some additional details:
- Which desktop environment are you using?
- Which tool are you using to switch keyboard layouts (setxkbmap, loadkeys, localectl, /etc/default/keyboard, etc)?
- Which language(s) or keyboard layout(s) are causing you trouble?
- What's the language/locale of your keyboard (QWERTY, QWERTZ, AZERTY, ÄWERTY, etc)
- GNOME 46 Wayland
- To switch the keyboard layout, I use the default hotkey in the Gnome environment "super + spacebar". The language switches, but the hotkeys inside zed stop working.
- Hotkeys do not work when the Russian keyboard is on
- My keyboard has 2 layouts: Russian and English (QWERTY/ЙЦУКЕН)
KDE 6.1.2 Wayland Fedora 40, rpm from Terra The same issue, the same layouts
same issue. ubuntu 24.04 gnome 46, qwerty/йцукен (eng/rus)
GNOME 42.9, Wayland Ubuntu 22.04.4 2 layouts: Russian and English (QWERTY/ЙЦУКЕН) The same issue
Not using the Russian layout but, using keycodes for stuff like the ` key instead of the actual character would help here as well i.e. if we can press the "key under esc" regardless of the layout. Because on mine the ` character is at AltGr + "," so doing Ctrl+AltGr+, is quite inconvenient :sweat_smile:
MacOS has the same issue with shortcuts that use Opt key (for example Opt+T for a task run).
Tested on MacBook Air M1, Sonoma 14.5
MacOS has the same issue with shortcuts that use
Optkey (for exampleOpt+Tfor a task run). Tested on MacBook Air M1, Sonoma 14.5
@quendimax Please do not hijack this thread one with off-topic comments, this is a linux specific keyboard layout issue. Please open a new issue if you're having trouble.
FYI your issue is likely because Opt+T is invalid. 1. Zed use lowercase alt on all platforms rather than the MacOS specific Option or Opt. 2. Zed use - not +.
Any of these should work: alt-t, alt-shift-t, alt-T -- if not open a new issue.
I have the same/similar issue, but on macOS, using Zed v0.149.0. Let me know if this goes into this existing issue or if I should file a new one.
- For me, it's switching window focus stopped working in Zed (it works elsewhere in macOS). It's cmd+`.
- I can still use
cmd+s, cmd+cetc, however. So it's not as severe as OP's issue. - I'm using Swedish as input language.
- If I switch back to English (US) input language, I cannot repro.
macOS keyboard settings
- Which desktop environment are you using? macOS
- Which tool are you using to switch keyboard layouts (setxkbmap, loadkeys, localectl, /etc/default/keyboard, etc)? None.
- Which language(s) or keyboard layout(s) are causing you trouble? Swedish.
- What's the language/locale of your keyboard (QWERTY, QWERTZ, AZERTY, ÄWERTY, etc). QWERTY.
Zed specs Zed: v0.149.0 (Zed Preview) OS: macOS 14.4.0 Memory: 32 GiB Architecture: aarch64
@brookback Please file a new issue as your issue on MacOS is likely distinct. Please include full reproduction steps if possible. Thanks.
same issue. nixos-unstable hyprland 0.42.0, qwerty/йцукен (eng/rus)
Same issue on Ubuntu 24.04 LTS, Wayland session, Canadian Multilingual layout. Mapping on the Quote ' key does not work (it's "è"), nor does the \ key (it's "à").
In VS Code, it maps ctrl+' (ctrl+è on the Canadian Multilingual layout) as ctrl-[Quote].
There is an active discussion going on here:
- https://github.com/zed-industries/zed/discussions/17031
We'd love to gather input from folks who are using international keyboards with Zed.
v0.162.x fixes most problems for macOS, so now Linux...
The goal here is to make the gpui platform implementation consistent with the macOS one, so:
- For layouts which generate a different key when the platform modifier is down, we should use that as the basis of the keybindings. (so, ctrl-я becomes ctrl-q)
- For layouts with dead-keys, we should generate a shortcut press for the dead key (so that ctrl-^ works, and even ^ to go to start of line in vim mode); we also need to generate shortcuts before IME if an IME is not in progress (so vim mode works on Japanese keyboards).
- We also want to copy the changes for Extended Latin keyboards. For macOS, we copy the key equivalents from the OS; for Linux I'm not sure we can copy equivalents from anywhere (is there already a convention about what to do about ctrl-[ when [ requires alt to type?). We could possibly copy VSCode's logic if we want to avoid creating our own.
I took a bit of a look, and found that the first problem is that for non-Latin layouts that should have a different character when the platform modifier is pressed, we don't correctly read that even though xev does.
If anyone has done key handling on Linux before, I'd love to pair with you: https://calendly.com/conradirwin/pairing.
yeaaaahhh i have the same issue qwerty/йцукен (eng(US)/rus)
@VyacheslavKuchumov are you on macOS or Linux? If Linux, are you on Wayland or X11, and which IME system do you use?
Same issue with Ukrainian (QWERTY/ЙЦУКЕН) on Linux (Fedora Workstation), Wayland, GNOME 47
Besides from mentioned above with extended keyboards and modifiers, I'm wondering is there anything blocking to use key/scan codes rather than key names? I.e. instead of mapping dozens of keys like й to q for ctrl + q, it could be something like ctrl + key:81?
@ExposedCat I'd like this to work by default - so we don't need mappings in most cases. How other apps on Linux work; but it's not totally clear to me (and probably not as standardized as it is on macOS).
For example I know if I use a Cyrillic keyboard, then shortcuts like ctrl-shift-n for new window in Gnome terminal still work. Is that because they are bound to the key code, or is it because they are bound to a layer on your keyboard that generates ASCII still?
@ConradIrwin can this be used?
However I'm not sure how to get these codes from rust without root access to /dev/input or device list
Has this issue been resolved? I am using a Macbook Pro M4 with a Swedish layout. Shortcuts like toggling line comments do not work with swedish input.
@RasmusHogslatt on a Swedish keyboard toggle comments is now cmd-´
@ConradIrwin I got back and tried this. Your comment was correct, and it reflects my setup, but for whatever reason, instead of toggling comments it opens the "Help" window for zed in the top menubar. Is that expected behaviour?
@RasmusHogslatt that is not expected; part of the reason to move these shortcuts around is to avoid the builtin macOS shortcuts.
Are you also using the Swedish locale? What's the default help menu shortcut?
I'm also using the Swedish layout, and can reproduce what @RasmusHogslatt is running into: when using the keyboard shortcut, the native macOS help menu is shown instead.
(It's been like this for a long time, so I just rebinded the shortcut to something else.)
Edit: I have a theory it's like this:
- If you read https://github.com/zed-industries/zed/blob/main/crates/settings/src/key_equivalents.rs#L1186, you'll see that
/maps to´. Toggle commentsis bound to´.- The Swedish layout for entering
/isshift+7, socmd+/becomescmd+shift+7. - This keyboard shortcut is somehow triggering macOS's help menu.
Should we adjust the macOS Swedish layout equivalents to be less intrusive by default?
"com.apple.keylayout.Swedish" => &[
// Copied from macOS
// Move the window switching shortcuts to match the default Swedish locale
('`', '<'),
('~', '>'),
('<', ';'),
('>', ':'),
(':', 'Å'),
(';', 'å'),
// Move these untypable "pairs" to typeable pairs (so indent/outdent feel similar)
('{', 'Ö'),
('}', 'Ä'),
('[', 'ö'),
(']', 'ä'),
// keep cmd-shift-{3,4,5} in the same place as it's used for macOS screenshots by default
('$', '€'),
// Deviate from macOS (and current Zed)
// There are three remaining ASCII characters that require option to type on a Swedish keyboard,
// assign these to the three remaining characters that don't require option to type.
('@', '¨'),
('\\', '´'),
('|', '`'),
// remove all these...
// ('"', '^'),
// ('&', '/'),
// ('(', ')'),
// (')', '='),
// ('*', '('),
// ('^', '&'),
// ('/', '´'),
// ('=', '`'),
// ('\'', '¨'),
],
What is the default help shortcut in the Swedish locale? I also want to make sure we're not going to crash into it.
See also https://github.com/zed-industries/zed/issues/20425#issuecomment-2533543683 for similar woes with German and a proposed new default.
same issue with en/ru kb layout.
endeavouros arch distro, x11 desktop (awesome)
I have same issue, shortcuts like ctrl+c and ctrl+v etc. Works only when active system layout is QWERTY, any other non latin layout breaks shortcuts.
Zed version: 0.166.1
OS: Fedora Linux 41 (Wayland)
This issue not reproduced in other editors, vscode for example.
Would like have an option that switches all shortcuts to keycode bind instead of char
There was a similar problem for Cyrillic keyboard on Ubuntu. I share the solution
-
Ctrl+Shift+P --> (execute command) debug: open key context view
-
Press all the necessary key combinations and save their designations For example, Last Keystroke: Typed: "ctrl-cyrillic_em" = CTRL+M(cyrillic) ..... and others
-
Menu - Open Key BIndings - add combinations (For example for cyrillic keyboard) { "context": "Editor", "bindings": { "ctrl-cyrillic_es":"editor::Copy", "ctrl-cyrillic_em":"editor::Paste", "ctrl-cyrillic_che": "editor::Cut", "ctrl-cyrillic_ef":"editor::SelectAll", "ctrl-cyrillic_ya": "editor::Undo", "ctrl-cyrillic_en": "editor::Redo", "ctrl-cyrillic_a": "buffer_search::Deploy" } }
-
worked
@neodraw - amazing, thank you
I wrote a script that translates shortcuts into Cyrillic, so you can use or copy the already translated file localized_keymap.json here is the link to the script https://github.com/Randommist/zed-cyrillic