zed icon indicating copy to clipboard operation
zed copied to clipboard

Custom keyboard shortcuts not working with non-default keyboard layouts on MacOS

Open alexander-irbis opened this issue 9 months ago • 3 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

Case 1:

  1. Activate the "Toggle Base Keymap Selector" and select "JetBrains."
  2. Open "keymap.json" in the editor, for example.
  3. Set your system keyboard layout to a national layout, e.g., Ukrainian.
  4. Place the cursor on any "cmd" string and press ctrl-g.

Expected Result: The "cmd" under the cursor is selected, and subsequently, every next "cmd" in the file is selected one by one.

Actual Result: The "go to line" action is triggered.

Case 2:

  1. Add custom bindings in "keymap.json," e.g.:
    "cmd-a": null,
    "cmd-a p": "projects::OpenRecent",
  1. Set your system keyboard layout to the Ukrainian layout.
  2. Press the keys in the sequence "cmd-a p."

Expected Result: The "Open Recent Projects" action is triggered.

Actual Result: The "з" symbol is entered.

The sequence "cmd-a cmd-p" works fine. However, neither "cmd-a ctrl-p", "cmd-a alt-p", nor "cmd-a p" work.

Environment

Zed: v0.132.2 (Zed) OS: macOS 14.4.1 Memory: 64 GiB Architecture: aarch64

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

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

alexander-irbis avatar Apr 25 '24 06:04 alexander-irbis

I found #10953 to be similar to this issue, because the video shows a "HU" layout.

alexander-irbis avatar Apr 25 '24 06:04 alexander-irbis

I found #10953 to be similar to this issue, because the video shows a "HU" layout.

Changing my keyboard layout to US or ABC doesn't solve the issue with ctrl-h in particular on my end.

Do your overrides start working if you switch your layout?

xezrunner avatar Apr 25 '24 17:04 xezrunner

Yes, my overrides work fine when I switch to the ABC layout.

I have also tried the QZ layout (the German QWERTZ, where Y and Z are swapped), and my overrides still work well.

However, when I tried Cmd+Z, it appears to be activated by my physical Cmd+Y. I wonder if this is common for German users. At least on my system in Safari, it works the same way. Meanwhile, for Ukrainian and Russian layouts, it is common to use standard "physical" English keys for shortcuts.

This complicates universal support for national standards, as it requires conducting extensive research. Perhaps in this case, it would be simpler to initially provide an option to 'use the default layout for shortcuts,' to at least solve the problem for some users.

ChatGPT suggests that in some versions of macOS, it is possible to set a system-wide option to use the same keyboard layout for shortcuts, which maintains shortcut consistency across different language layouts. However, in the latest version of macOS, I was unable to find this option, so I cannot try it out and share how it works.

alexander-irbis avatar Apr 26 '24 12:04 alexander-irbis

Having the same issue on linux with wayland compositor. Here is my issue https://github.com/zed-industries/zed/issues/12329

unkindypie avatar May 27 '24 15:05 unkindypie

+1

MaxThom avatar May 30 '24 03:05 MaxThom

I found some interesting behaviour on a german QWERTZ Layout on Linux (Wayland & X11)

On a german QWERTZ layout the forward slash (/) is on (shift-7) and the ampersand (&) is on (shift-6)

I tried to make the "editor::ToggleComments" comand to work as expected, which would be (ctrl-shift-7) on VSCode with a german layout. I got it working by setting:

{
  "ctrl-shift-/": ["editor::ToggleComments", { "advance_downwards": false }]
}

"ctrl-shift-7" and "ctrl-/" did not work.

But when i try it with the ampersand, i have to set:

{
  "ctrl-&": ["editor::ToggleComments", { "advance_downwards": false }]
}

"ctrl-shift-6" and "ctrl-shift-&" did not work.

Why is there a difference so that pressing ctrl + amp (ctrl-shift-6) got interpreted as (ctrl-&) but pressing ctrl + forward slash (ctrl-shift-7) got interpred as (ctrl-shift-/)?

I think the difference in the interpretation is the reason why this keybinding (and many more) don't work out of the box on german layouts. It seams that some special keys require the shift keyword in their bindings and other do not, no matter they all acctually need shift to be pressed on a QWERTZ Layout.

Is there any plan to implement a visual keybinding editor or a keybinging tester (where i can press a key combo and get the interpreted result back)?

In VSCode i actually have to set "ctrl-shift-6" or "ctrl-shift-7" in the config. This does not mean "you should do it like VSCode" but i found it interessting that there seams to be quite a difference in interpreting keystrokes.

I think which ever way Zed goes it should be consistent. Right now i have to guess and try multiple keybindings out a QWERTZ layout.

derappelt avatar Jul 10 '24 18:07 derappelt

A similar issue happens for spanish layout with keys with characters that are not 'final' like ´ `, where the key is not recognized.

image

This should be the keymap for indent/outdent to match my other editors:

[
  {
    "context": "Editor",
    "bindings": {
      "alt-cmd-`": "editor::Outdent", // doesn't work
      "alt-cmd-+": "editor::Indent",  // works
    }
  }
]

guillemap avatar Jul 11 '24 14:07 guillemap

So, any fixes for that?

On my Ukrainian/russian layout even ctrl+c abs ctrl*v don't work

nanolookc avatar Sep 14 '24 11:09 nanolookc