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

Linux Shortcuts don't work with non-latin / international keyboard layouts #14053

Open
1 task done
leonovk opened this issue Jul 10, 2024 · 29 comments
Open
1 task done
Labels
bug [core label] keybinds Keyboard shortcuts, mapping, binding, keymaps, etc linux

Comments

@leonovk
Copy link

leonovk commented Jul 10, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

If you switch the keyboard layout to another language, the hotkeys stop working. For example ctrl + s or ctrl + c

Environment

zed installed for arch linux https://archlinux.org/packages/extra/x86_64/zed/

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log
@leonovk leonovk added admin read bug [core label] labels Jul 10, 2024
@notpeter
Copy link
Member

Can you provide some additional details:

  1. Which desktop environment are you using?
  2. Which tool are you using to switch keyboard layouts (setxkbmap, loadkeys, localectl, /etc/default/keyboard, etc)?
  3. Which language(s) or keyboard layout(s) are causing you trouble?
  4. What's the language/locale of your keyboard (QWERTY, QWERTZ, AZERTY, ÄWERTY, etc)

@notpeter notpeter added linux keybinds Keyboard shortcuts, mapping, binding, keymaps, etc and removed triage labels Jul 10, 2024
@leonovk
Copy link
Author

leonovk commented Jul 10, 2024

  1. GNOME 46 Wayland
  2. 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.
  3. Hotkeys do not work when the Russian keyboard is on
  4. My keyboard has 2 layouts: Russian and English (QWERTY/ЙЦУКЕН)

@AndyDroid10X
Copy link

AndyDroid10X commented Jul 11, 2024

KDE 6.1.2 Wayland
Fedora 40, rpm from Terra
The same issue, the same layouts

@yournumberone
Copy link

same issue. ubuntu 24.04 gnome 46, qwerty/йцукен (eng/rus)

@ruskiiamov
Copy link

GNOME 42.9, Wayland
Ubuntu 22.04.4
2 layouts: Russian and English (QWERTY/ЙЦУКЕН)
The same issue

@Beryesa
Copy link

Beryesa commented Jul 18, 2024

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 😅

@notpeter notpeter changed the title Hotkeys do not work if you switch keyboard layouts Hotkeys do not work on alternate keyboard layouts Jul 25, 2024
@notpeter notpeter changed the title Hotkeys do not work on alternate keyboard layouts Shortcuts don't work with non-latin / international keyboard layouts Jul 25, 2024
@quendimax

This comment was marked as off-topic.

@notpeter

This comment was marked as off-topic.

@brookback

This comment has been minimized.

@notpeter
Copy link
Member

@brookback Please file a new issue as your issue on MacOS is likely distinct. Please include full reproduction steps if possible. Thanks.

@D3st0ny
Copy link

D3st0ny commented Aug 24, 2024

same issue. nixos-unstable hyprland 0.42.0, qwerty/йцукен (eng/rus)

@SylChamber
Copy link

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].

@notpeter
Copy link
Member

notpeter commented Sep 3, 2024

There is an active discussion going on here:

We'd love to gather input from folks who are using international keyboards with Zed.

@ConradIrwin
Copy link
Member

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.

@VyacheslavKuchumov
Copy link

yeaaaahhh i have the same issue qwerty/йцукен (eng(US)/rus)

@ConradIrwin
Copy link
Member

@VyacheslavKuchumov are you on macOS or Linux? If Linux, are you on Wayland or X11, and which IME system do you use?

@ExposedCat
Copy link

ExposedCat commented Nov 22, 2024

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?

@ConradIrwin
Copy link
Member

@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?

@ExposedCat
Copy link

ExposedCat commented Nov 23, 2024

@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

@RasmusHogslatt
Copy link

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.

@ConradIrwin
Copy link
Member

ConradIrwin commented Dec 6, 2024

@RasmusHogslatt on a Swedish keyboard toggle comments is now cmd-´

Screenshot 2024-12-06 at 09 52 42

@RasmusHogslatt
Copy link

@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?

@ConradIrwin
Copy link
Member

@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?

@brookback
Copy link

brookback commented Dec 9, 2024

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:

  1. If you read https://github.com/zed-industries/zed/blob/main/crates/settings/src/key_equivalents.rs#L1186, you'll see that / maps to ´.
  2. Toggle comments is bound to ´.
    image
  3. The Swedish layout for entering / is shift+7, so cmd+/ becomes cmd+shift+7.
  4. This keyboard shortcut is somehow triggering macOS's help menu.

@ConradIrwin
Copy link
Member

ConradIrwin commented Dec 11, 2024

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 #20425 (comment) for similar woes with German and a proposed new default.

@bnn1
Copy link

bnn1 commented Dec 17, 2024

same issue with en/ru kb layout.

endeavouros arch distro, x11 desktop (awesome)

@Akiyamka
Copy link

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

@SomeoneToIgnore SomeoneToIgnore marked this as a duplicate of #23295 Jan 17, 2025
@ConradIrwin ConradIrwin changed the title Shortcuts don't work with non-latin / international keyboard layouts Linux Shortcuts don't work with non-latin / international keyboard layouts Feb 6, 2025
@neodraw
Copy link

neodraw commented Feb 13, 2025

There was a similar problem for Cyrillic keyboard on Ubuntu. I share the solution

  1. Ctrl+Shift+P --> (execute command) debug: open key context view

  2. Press all the necessary key combinations and save their designations
    For example, Last Keystroke: Typed: "ctrl-cyrillic_em" = CTRL+M(cyrillic) ..... and others

  3. 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"
    }
    }

  4. worked

@Akiyamka
Copy link

@neodraw - amazing, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] keybinds Keyboard shortcuts, mapping, binding, keymaps, etc linux
Projects
No open projects
Archived in project
Development

No branches or pull requests