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

Keyboard shortcuts wrong keyboard layout detection #2731

Open
RichardFevrier opened this issue Oct 31, 2023 · 44 comments
Open

Keyboard shortcuts wrong keyboard layout detection #2731

RichardFevrier opened this issue Oct 31, 2023 · 44 comments
Labels
A-keymap Area: default key bindings C-bug Category: bug - something isn't working as it's supposed to

Comments

@RichardFevrier
Copy link

RichardFevrier commented Oct 31, 2023

Lapce Version

nightly-b4a6ec5

System information

Fedora Silverblue 38 Hyprland

Describe the bug

Using a non QWERTY keyboard resulting in wrong keys detection in the Keyboard Shortcuts section.

E.g.
Remapping Ctrl+z is detected as Ctrl+w for undo.

In the rest of the editor everything seems working correctly even pressing Ctrl+z really performs undo action (after remapping, read my paragraph below).

Why it is really a problem?
Because by default Ctrl+z is mapped to closing the file like a Ctrl+w would do... So non QWERTY keyboard users have to remap all non equivalent default shorcuts.

@RichardFevrier RichardFevrier added the C-bug Category: bug - something isn't working as it's supposed to label Oct 31, 2023
@zadjadr
Copy link

zadjadr commented Nov 2, 2023

This might be a hyprland issue, as far as I know: wayland will set the keyboard settings via xorg.

In my case, hyprland sets the layout correctly (Z is where it physically is), but reports the "us" layout to xorg:

❯ setxkbmap -query
WARNING: Running setxkbmap against an Xwayland server
rules:      evdev
model:      pc105
layout:     us

I have no workaround, yet.

@RichardFevrier
Copy link
Author

Read carefully your output WARNING: Running setxkbmap against an Xwayland server
XWayland, not wayland.
Nothing related to hyprland, it was working properly in version 0.2.8 this is a regression.

@MinusGix MinusGix added the A-keymap Area: default key bindings label Nov 4, 2023
@Mforcen
Copy link

Mforcen commented Nov 4, 2023

Keybindings do not work properly also in non-us keyboard layouts. For example I have the es-ES layout and I have to use the keys in the us layout for commands to be launched.

@joshkamm
Copy link

joshkamm commented Nov 5, 2023

I'm noticing a similar experience using DVORAK layout on a laptop's QWERTY hardware keyboard on Windows 10, where in version 0.3.0 the Ctrl key bindings are based on their hardware QWERTY positions while in version 0.2.8 they were based on their DVORAK positions.

P.S. Thanks to everyone who volunteers their time to this project. I recently came across it and it looks cool!

@LuckyTurtleDev
Copy link

I'm noticing a similar experience using DVORAK layout on a laptop's QWERTY hardware keyboard on Windows 10.

Same with koy on QWERTZ at arch linux.

An overview of some shortcuts:
strg + h save all
strg + ä copy
strg + ü insret
strg + v undo
strg + x redo
strg + a save

This make lapce is unusable for me.

@souze
Copy link

souze commented Nov 14, 2023

Same problem for me, on Ubuntu 22.04, Regolith Desktop Environment (Xorg, I3 on top of GNOME).

Also the normal mode vim-like bindings are wrong (mapped as if I was on US QWERTY).

@saccarosium
Copy link

Same problem on MacOS 14.1.1 with Dvorak

@iltumio
Copy link

iltumio commented Dec 9, 2023

Same for me. Mac OS 14.1.2 with Dvorak layout. Lapce 0.3.1. Physical keyboard is a QWERTY, but the layout configured on the mac is Dvorak US. Looks like the app still see it as QWERTY. The problem started to happen after the recent update that introduced Floem for the UI

@faern
Copy link

faern commented Dec 13, 2023

Just wanting to add my +1 to this issue. Discovered and tried out lapce for the first time today. Looks really promising to be honest! Great work devs ✨ Sadly it's currently not usable since basically all hotkeys use the wrong keys to be activated.

I'm using lapce 0.3.1 via flatpak on Fedora with sway right now. My keyboard layout is custom (should not matter which one, just not qwerty)

@owenbrown
Copy link

I use a non-US keyboard layout, so this also makes the product unusable for me.
It prevents me from even testing it.

@chmousset
Copy link

same thing here with fr layout.
Older (March 2023) release of Lapce worked correctly.

> setxkbmap -query                                                                                                                      ✔ 
rules:      evdev
model:      pc104
layout:     fr

@ruabmbua
Copy link

I am running sway, and launching without xwayland (force disabled).
Keyboard layout is QWERTZ, and my system keyboard layout is also set to QWERTZ(german keyboard layout).

The editor functions normally, just keyboard shortcuts do not work correctly.
Sometimes the keyboard shortcuts seem to work for a short while, when I re-focus the editor window.

@ruabmbua
Copy link

I am hitting the same problem on vscode in wayland mode now.
I have no clue what is going on, but its again only for keyboard shortcuts in the editor.

I think there is something seriously wrong. This all worked in the past, I am not sure any more if its an issue with lapce / vscode or with some other component...

@saccarosium
Copy link

Hey @ruabmbua, I've tried vscode on gnome, under wayland, an I didn't have encounter this problem. Try to see if it is a problem with wlroots witch is the library that sway is based on.

@melMass
Copy link

melMass commented Feb 9, 2024

Same on windows with an AZERTY layout

@LuckyTurtleDev
Copy link

Anything new at this issue? It is a big deal breaker which make lape useless for all non us people/keyboards.

@ruabmbua
Copy link

I have reproduced the issue at least one time in gnome now.

@panekj
Copy link
Collaborator

panekj commented Feb 18, 2024

Anything new at this issue? It is a big deal breaker which make lape useless for all non us people/keyboards.

If there will be, it will be mentioned in this issue

@sorcerersr
Copy link

I'm affected by this issue as well and tried to analyze what may causing this issue.

On a german keyboard layout (qwertz) when pressing Ctrl+Z the incoming KeyEvent is

Keyboard(KeyEvent { key: KeyEvent { physical_key: Code(KeyY), logical_key: Character("z"), text: Some("z"), location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Character("z"), text_with_all_modifiers: Some("\u{1a}") } }, modifiers: ModifiersState(CONTROL) })

which is mapped to

KeyPress { key: Keyboard(Character("z"), Code(KeyY)), mods: ModifiersState(CONTROL) }

that is then used to find a command to be executed.

I experimented a little bit and tried to use the value from the logical_key to get the corresponding KeyCode to appear in the resulting KeyPress.
When pressing Ctrl+Z on a qwertz keyboard I wanted the Keypress to look like this

KeyPress { key: Keyboard(Character("z"), Code(KeyZ)), mods: ModifiersState(CONTROL) }

See my PR #3001

It think this can fix many of the keyboard layout related issues but unfortunately not all.
For example Ctrl+= is still not working (this is the default for zoom-in).
On a german keyboard the equal sign "=" is reached by pressing Shift+0.
The KeyEvent for this case will be Ctrl+Shift+= which obiously doesn't match the keybind Ctrl+=.

So not a final solution, but a first step :)

@panekj
Copy link
Collaborator

panekj commented Feb 22, 2024

There is already PR opened (#2637) to fix the problem and issue for discussion (#2636)

@dzhou121
Copy link
Collaborator

This is potentially fixed by #3119

@dzhou121
Copy link
Collaborator

@RichardFevrier Would love to hear your feedback if the PR fixes the issue for you. It should be available on the latest nightly build.

@RichardFevrier
Copy link
Author

Thanks for asking @dzhou121

Just tested and it's working well for some shortcuts not so much for some others (I have deleted the entire .config/lapce-nightly first).

E.g.
Ctrl + z working well out of the box now!
Ctrl + / (toggle comment) not working, and if i check to remap it, it was recognized as Ctrl + Shift + :

Maybe something on my side, I've tested 2 differents linux desktop environment (Gnome and Niri both under Wayland) so if some people using linux from this conversation would mind to test also that would be nice.

Thanks for reading me.

@saccarosium
Copy link

I'm happy to report that the keybindings works with no problem here on Debian 12 Gnome Wayland with dvorak.

@dzhou121
Copy link
Collaborator

dzhou121 commented Mar 28, 2024

Thanks for asking @dzhou121

Just tested and it's working well for some shortcuts not so much for some others (I have deleted the entire .config/lapce-nightly first).

E.g. Ctrl + z working well out of the box now! Ctrl + / (toggle comment) not working, and if i check to remap it, it was recognized as Ctrl + Shift + :

Maybe something on my side, I've tested 2 differents linux desktop environment (Gnome and Niri both under Wayland) so if some people using linux from this conversation would mind to test also that would be nice.

Thanks for reading me.

Can I ask what's your keyboard layout? And out of interest, how does it look like in VSCode when you click Ctrl+/ when you try to bind something in keyboard shortcuts?

@LuckyTurtleDev
Copy link

LuckyTurtleDev commented Mar 29, 2024

Can confirm that the shortcuts seems to work again (german key board + koy layout) on commit 21e6719.

But it looks like strg + + does still not work for zooming. But strg + - works. (I am not sure if I had accidentally disable it, but I was not able to find the keyboard shortcut section in the settings.

Update:
found shortcut settings. Zoom was set to strg + =. But after changing it does still not work. In the shortcut overview it does show strg+ instead of strg++.
image

@dzhou121
Copy link
Collaborator

Can confirm that the shortcuts seems to work again (german key board + koy layout) on commit 21e6719.

But it looks like strg + + does still not work for zooming. But strg + - works. (I am not sure if I had accidentally disable it, but I was not able to find the keyboard shortcut section in the settings.

Update: found shortcut settings. Zoom was set to strg + =. But after changing it does still not work. In the shortcut overview it does show strg+ instead of strg++. image

Thanks for testing it. Can you please see what was the raw keyboard event in Lapce logs when you press Ctrl++

@LuckyTurtleDev
Copy link

LuckyTurtleDev commented Mar 29, 2024

Can confirm that the shortcuts seems to work again (german key board + koy layout) on commit 21e6719.
But it looks like strg + + does still not work for zooming. But strg + - works. (I am not sure if I had accidentally disable it, but I was not able to find the keyboard shortcut section in the settings.
Update: found shortcut settings. Zoom was set to strg + =. But after changing it does still not work. In the shortcut overview it does show strg+ instead of strg++. image

Thanks for testing it. Can you please see what was the raw keyboard event in Lapce logs when you press Ctrl++

Dump question, but how do I get logs? I have try RUST_LOG=debug lapce -w but it does not output anything.

One additional information: the shortcut preview show correctly ctrl++ but after pressing save it shows only ctrl+
image

@dzhou121
Copy link
Collaborator

Can confirm that the shortcuts seems to work again (german key board + koy layout) on commit 21e6719.
But it looks like strg + + does still not work for zooming. But strg + - works. (I am not sure if I had accidentally disable it, but I was not able to find the keyboard shortcut section in the settings.
Update: found shortcut settings. Zoom was set to strg + =. But after changing it does still not work. In the shortcut overview it does show strg+ instead of strg++. image

Thanks for testing it. Can you please see what was the raw keyboard event in Lapce logs when you press Ctrl++

Dump question, but how do I get logs? I have try RUST_LOG=debug lapce -w but it does not output anything.

One additional information: the shortcut preview show correctly ctrl++ but after pressing save it shows only ctrl+ image

You can search "open log" in command palette. But I see it's a bug now, when we try to parse the keymap, we simply string.split('+') and it gets rid of the last +.

@dzhou121
Copy link
Collaborator

Can confirm that the shortcuts seems to work again (german key board + koy layout) on commit 21e6719.
But it looks like strg + + does still not work for zooming. But strg + - works. (I am not sure if I had accidentally disable it, but I was not able to find the keyboard shortcut section in the settings.
Update: found shortcut settings. Zoom was set to strg + =. But after changing it does still not work. In the shortcut overview it does show strg+ instead of strg++. image

Thanks for testing it. Can you please see what was the raw keyboard event in Lapce logs when you press Ctrl++

Dump question, but how do I get logs? I have try RUST_LOG=debug lapce -w but it does not output anything.

One additional information: the shortcut preview show correctly ctrl++ but after pressing save it shows only ctrl+ image

should be fixed by 0f90906

@LuckyTurtleDev
Copy link

It works now for numeric keypad again. But for the other + at keyboard layer 3 does still not work.
If I try to use the other + as shortcut with ctrl I get this:
image
Maybe lapce get confused by the unusual layout.
koy layer3:
image

log:

2024-03-29T20:11:42.650499Z DEBUG lapce_app::keypress: Keyboard(KeyEvent { key: KeyEvent { physical_key: Code(ControlLeft), logical_key: Named(Control), text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Named(Control), text_with_all_modifiers: None } }, modifiers: ModifiersState(0x0) })
2024-03-29T20:11:43.449949Z DEBUG lapce_app::keypress: Keyboard(KeyEvent { key: KeyEvent { physical_key: Code(CapsLock), logical_key: Named(AltGraph), text: None, location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Named(AltGraph), text_with_all_modifiers: None } }, modifiers: ModifiersState(CONTROL) })
2024-03-29T20:11:44.433948Z DEBUG lapce_app::keypress: Keyboard(KeyEvent { key: KeyEvent { physical_key: Code(KeyM), logical_key: Character("%"), text: Some("%"), location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Character("p"), text_with_all_modifiers: Some("%") } }, modifiers: ModifiersState(CONTROL) })

@dzhou121
Copy link
Collaborator

It works now for numeric keypad again. But for the other + at keyboard layer 3 does still not work. If I try to use the other + as shortcut with ctrl I get this: image Maybe lapce get confused by the unusual layout. koy layer3: image

log:

2024-03-29T20:11:42.650499Z DEBUG lapce_app::keypress: Keyboard(KeyEvent { key: KeyEvent { physical_key: Code(ControlLeft), logical_key: Named(Control), text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Named(Control), text_with_all_modifiers: None } }, modifiers: ModifiersState(0x0) })
2024-03-29T20:11:43.449949Z DEBUG lapce_app::keypress: Keyboard(KeyEvent { key: KeyEvent { physical_key: Code(CapsLock), logical_key: Named(AltGraph), text: None, location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Named(AltGraph), text_with_all_modifiers: None } }, modifiers: ModifiersState(CONTROL) })
2024-03-29T20:11:44.433948Z DEBUG lapce_app::keypress: Keyboard(KeyEvent { key: KeyEvent { physical_key: Code(KeyM), logical_key: Character("%"), text: Some("%"), location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Character("p"), text_with_all_modifiers: Some("%") } }, modifiers: ModifiersState(CONTROL) })

Was it AltGraph that changed it to layer 3?

@LuckyTurtleDev
Copy link

At the quertz layout at this position is caps lock. At the grafic it is called M3.

@NicoAdrian
Copy link

Same problem with MacOS Sonoma (french keyboard - AZERTY). Good editor and looks promising but unusable when trying to add/change new keybindings

@dzhou121
Copy link
Collaborator

dzhou121 commented Apr 1, 2024

At the quertz layout at this position is caps lock. At the grafic it is called M3.

should be fixed by #3143, can you please test it?

@RichardFevrier
Copy link
Author

Just to add some infos about my previous comment:

Ctrl + / (toggle comment) not working, and if i check to remap it, it was recognized as Ctrl + Shift + :

I have checked my inputs with wev from the lapce console. And I can confirm that / is outputed.
Here it is if it can help:

[14:     wl_keyboard] key: serial: 21542; time: 3610605; key: 62; state: 1 (pressed)
                      sym: Shift_R      (65506), utf8: ''
[14:     wl_keyboard] modifiers: serial: 21542; group: 0
                      depressed: 00000001: Shift
                      latched: 00000000
                      locked: 00000000
[14:     wl_keyboard] key: serial: 21543; time: 3610860; key: 60; state: 1 (pressed)
                      sym: slash        (47), utf8: '/'

@dzhou121
Copy link
Collaborator

dzhou121 commented Apr 6, 2024

Just to add some infos about my previous comment:

Ctrl + / (toggle comment) not working, and if i check to remap it, it was recognized as Ctrl + Shift + :

I have checked my inputs with wev from the lapce console. And I can confirm that / is outputed. Here it is if it can help:

[14:     wl_keyboard] key: serial: 21542; time: 3610605; key: 62; state: 1 (pressed)
                      sym: Shift_R      (65506), utf8: ''
[14:     wl_keyboard] modifiers: serial: 21542; group: 0
                      depressed: 00000001: Shift
                      latched: 00000000
                      locked: 00000000
[14:     wl_keyboard] key: serial: 21543; time: 3610860; key: 60; state: 1 (pressed)
                      sym: slash        (47), utf8: '/'

I get what you mean. But it’s the logic of Lapce that if shift is pressed, then we’ll use shift+key_before_modifier as the input.

@RichardFevrier
Copy link
Author

I see now; thanks for the explanation!
And since US/UK Qwerty / does not need Shift to be applied you did not encountered the problem.
But it still exists for the rest of the world, at least for european countries =)

@dzhou121
Copy link
Collaborator

dzhou121 commented Apr 6, 2024

I see now; thanks for the explanation! And since US/UK Qwerty / does not need Shift to be applied you did not encountered the problem. But it still exists for the rest of the world, at least for european countries =)

Yeah shift is a tricky one. We did this way because it's easier for capital letters. E.g. it's more obvious for shift+p than P in the key bindings.

@LuckyTurtleDev
Copy link

At the quertz layout at this position is caps lock. At the grafic it is called M3.

should be fixed by #3143, can you please test it?

sorry I was not able to test it until now. Because I did not have access to my tower last week and my laptop was not able to compile lapce, because it needs too much ram.

I have test it again with the lasted commit and get this now:
image

So it does still not detect it as Ctrl and +. Instead it use the modifier and p which is the key on this position without pressing the M3 modifier.
One thing I notify is that lapce did show Ctrl+AltGraph first and if i press +/p it changes to Ctrl+AltGr+p.
However the generated Ctrl+AltGr+p works for zooming.

Lapce hat also stop generating log for setting keyboard shortcuts. So I can not provide any.

@RichardFevrier
Copy link
Author

Just so you know there are nightly builds @LuckyTurtleDev

@dzhou121
Copy link
Collaborator

dzhou121 commented Apr 7, 2024

At the quertz layout at this position is caps lock. At the grafic it is called M3.

should be fixed by #3143, can you please test it?

sorry I was not able to test it until now. Because I did not have access to my tower last week and my laptop was not able to compile lapce, because it needs too much ram.

I have test it again with the lasted commit and get this now: image

So it does still not detect it as Ctrl and +. Instead it use the modifier and p which is the key on this position without pressing the M3 modifier. One thing I notify is that lapce did show Ctrl+AltGraph first and if i press +/p it changes to Ctrl+AltGr+p. However the generated Ctrl+AltGr+p works for zooming.

Lapce hat also stop generating log for setting keyboard shortcuts. So I can not provide any.

From the log you showed earlier, AltGr was sent to Lapce by winit when you press M3, so what I did is to recognise AltGr as a modifier, and then use the key_without_modifier which is p in this case. So it showed as ctrl+AltGr + p.

Take US layout for example, ! would be shown as shift+1 in keybindings.

@LuckyTurtleDev
Copy link

I found another issue. The arrow keys at layer 4 do also not work. At lapce 0.2.0 I was able to move the cursor with them. I was not able to reproduce this issue with any other software.

koy

@dzhou121
Copy link
Collaborator

I found another issue. The arrow keys at layer 4 do also not work. At lapce 0.2.0 I was able to move the cursor with them. I was not able to reproduce this issue with any other software.

koy

It's probably because of modifier key again, so it will recognise it as something + the base key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-keymap Area: default key bindings C-bug Category: bug - something isn't working as it's supposed to
Projects
None yet
Development

No branches or pull requests