Bug 492726

Summary: Shift key on neo layout not handled correctly
Product: [Applications] systemsettings Reporter: tm42 <t-m.42>
Component: kcm_keyboardAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED UPSTREAM    
Severity: normal CC: akselmo, butirsky, evgeniyharchenko.dev, fanzhuyifan, josh, jpetso, kde.org, natalie_clarius, nate
Priority: NOR    
Version First Reported In: 6.1.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=422401
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description tm42 2024-09-06 19:51:50 UTC
SUMMARY
Hello I hope I am in the right place here:

With my neo keyboard layout keyboard shortcuts terminate when hitting the Shift key.
The key event is "Shift+Caps_Lock" in Qt library and propagates to application shortcuts which cannot be used correctly (see https://github.com/qutebrowser/qutebrowser/issues/8285).
I am reporting here because it did work in Plasma 5 and also works in SwayWM with Qt6.

STEPS TO REPRODUCE
1.  Select neo2 keyboard layout
2.  Assign a keyboard shortcut with shift key
3. Shortcut cannot be triggered

OBSERVED RESULT
Keyboard shortcut stops parsing after hitting shift key.

EXPECTED RESULT
Keyboard shortcuts with shift keys should be correctly reported to applications.

SOFTWARE/OS VERSIONS
OS: Arch Linux
Keyboard layout: neo2
Linux/KDE Plasma: KDE Plasma 6.1/Wayland
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 24.08
Qt Version: 6.7

ADDITIONAL INFORMATION
Some key event outputs
```
$ xkbcli interactive-wayland
: keycode [ LFSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift ] leds [ ]
: keycode [ CAPS ] keysyms [ ISO_Level3_Shift            ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 0 ] mods [ Mod5 ] leds [ ]
: keycode [ CAPS ] keysyms [ ISO_Level3_Shift            ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 0 ] mods [ Mod5 ] leds [ ]
: keycode [ LFSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift ] leds [ ]
: keycode [ RTSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift ] leds [ ]
: keycode [ RTSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift ] leds [ ]
: keycode [ LFSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift ] leds [ ]
: keycode [ RTSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift Lock ] leds[ Caps Lock ]
: keycode [ CAPS ] keysyms [ ISO_Level3_Shift            ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 0 ] mods [ Lock Mod5 ] leds [Caps Lock ]
: keycode [ LFSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift Lock ] leds[ Caps Lock ]
: keycode [ RTSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift Lock ] leds[ Caps Lock ]
: keycode [ LFSH ] keysyms [ Caps_Lock                   ] unicode [   ] layout [ German (Neo 2) (0) ] level [ 1 ] mods [ -Shift ] leds [ ]
```
And the out of wev:
Interestingly it reports Caps_Lock on key down but Shift_L on key up. When I press the actual Caps Lock key it is correctly detected as ISO_Level3_Shift up/down.
```
[06:         wl_seat] capabilities: pointer keyboard
[06:         wl_seat] name:
[10:    xdg_toplevel] configure: width: 0; height: 0
[09:     xdg_surface] configure: serial: 28704
[14:     wl_keyboard] repeat_info: rate: 25 keys/sec; delay: 600 ms
[14:     wl_keyboard] keymap: format: 1 (xkb v1), size: 81094
[14:     wl_keyboard] enter: serial: 28708; surface: 3
'                     sym: Return       (65293), utf8: '
[14:     wl_keyboard] modifiers: serial: 0; group: 0
depressed: 00000000
latched: 00000000
locked: 00000000
[11:  wl_data_device] data_offer: id: 4278190080
[4278190080:   wl_data_offer] offer: mime_type: text/plain
[4278190080:   wl_data_offer] offer: mime_type: application/x-kde-onlyReplaceEmpty
[4278190080:   wl_data_offer] offer: mime_type: text/plain;charset=utf-8
[11:  wl_data_device] selection: id: 4278190080
[10:    xdg_toplevel] configure: width: 640; height: 480
activated
[09:     xdg_surface] configure: serial: 28711
[14:     wl_keyboard] key: serial: 28713; time: 15137025; key: 36; state: 0 (released)
sym: Return       (65293), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
depressed: 00000001: Shift
latched: 00000000
locked: 00000000
[14:     wl_keyboard] key: serial: 28717; time: 15138350; key: 50; state: 1 (pressed)
sym: Caps_Lock    (65509), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
depressed: 00000000
latched: 00000000
locked: 00000000
[14:     wl_keyboard] key: serial: 28721; time: 15139174; key: 50; state: 0 (released)
sym: Shift_L      (65505), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
depressed: 00000080: Mod5
latched: 00000000
locked: 00000000
[14:     wl_keyboard] key: serial: 28725; time: 15140019; key: 66; state: 1 (pressed)
sym: ISO_Level3_Shift (65027), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
depressed: 00000000
latched: 00000000
locked: 00000000
[14:     wl_keyboard] key: serial: 28729; time: 15141548; key: 66; state: 0 (released)
sym: ISO_Level3_Shift (65027), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
depressed: 00000001: Shift
latched: 00000000
locked: 00000000
[14:     wl_keyboard] key: serial: 28733; time: 15158220; key: 50; state: 1 (pressed)
sym: Caps_Lock    (65509), utf8: ''
[14:     wl_keyboard] key: serial: 28734; time: 15158774; key: 27; state: 1 (pressed)
sym: C            (67), utf8: 'C'
[14:     wl_keyboard] key: serial: 28735; time: 15159351; key: 27; state: 0 (released)
sym: C            (67), utf8: ''
[14:     wl_keyboard] modifiers: serial: 0; group: 0
depressed: 00000000
latched: 00000000
locked: 00000000
[14:     wl_keyboard] key: serial: 28739; time: 15159844; key: 50; state: 0 (released)
sym: Shift_L      (65505), utf8: ''
```
Comment 1 Akseli Lahtinen 2024-09-20 09:18:03 UTC
Here's something I found:

With neo2 keyboard layout, meta+shift+t keyboard shortcut I have worked just fine.

But with *any* layout, shift+capslock does not work.

Is this similar to what you're experiencing?
Comment 2 tm42 2024-09-20 18:29:48 UTC
Indeed it also appears with other layouts as well. However, I cannot assign meta+shift+t to anything, because after hitting meta+shift the shortcut is assigned to meta+shift+capslock without waiting for other keys.
Comment 3 fanzhuyifan 2024-09-20 22:30:14 UTC
The provided keymap indicates that your left shift is mapped to capslock, which is not a modifier. Currently our shortcut handling is based on Qt key codes, which is based on key syms, so unfortunately we won't be able to handle this situation. I am marking this as UPSTREAM, as what we are doing is consistent with how Qt processes shortcuts.

This has been requests to support shortcuts based on native key codes, e.g. see BUG 422401.