Not sure if it's related to #450, so I decided to create a new issue.
Also, not sure how to fix that in the keyboard's codebase, so I'll just post my solution that doesn't require patching anything.
keyboard==0.13.5, Windows 11, Python 3.10, a laptop with no numpad keys.
Pressing Shift+2while running will print shift+2 (works as intended).
(Same with Shift+4, Shift+6, Shift+8 and whatever other possible keys you register via add_hotkey, with (or without) any modifier key - Ctrl, Shift, etc)
But then, the weird stuff happens.
Pressing Shift + Down will trigger printing shift+2 (and that was unexpected, or so I thought).
Pressing Shift+Left triggers shift+4.
Pressing Shift+Right triggers shift+6.
Pressing Shift+Up triggers shift+8.
So, yeah, pressing any key combinations that contain left/down/up/right keys will trigger the registered hotkeys that contained numbers.
Solution/workaround
While trying to debug that, I noticed that you can also feed the actual keycodes to the add_hotkey function, so the following code behaves normally (although it's kinda confusing):
Not sure if it's related to #450, so I decided to create a new issue.
Also, not sure how to fix that in the
keyboard
's codebase, so I'll just post my solution that doesn't require patching anything.keyboard==0.13.5
, Windows 11, Python 3.10, a laptop with no numpad keys.Issue
A way to reproduce:
The code above will trigger
add_hotkey
->parse_hotkey_combinations
with these respective values:Pressing
Shift
+2
while running will printshift+2
(works as intended).(Same with Shift+4, Shift+6, Shift+8 and whatever other possible keys you register via add_hotkey, with (or without) any modifier key -
Ctrl
,Shift
, etc)But then, the weird stuff happens. Pressing
Shift
+Down
will trigger printingshift+2
(and that was unexpected, or so I thought).Pressing
Shift
+Left
triggersshift+4
.Pressing
Shift
+Right
triggersshift+6
.Pressing
Shift
+Up
triggersshift+8
.So, yeah, pressing any key combinations that contain left/down/up/right keys will trigger the registered hotkeys that contained numbers.
Solution/workaround
While trying to debug that, I noticed that you can also feed the actual keycodes to the
add_hotkey
function, so the following code behaves normally (although it's kinda confusing):This will use only the actual number keys and won't get triggered when you press the arrow keys.
parse_hotkey_combinations(hotkey)
results for the code above:Not sure how to fix that in the library code, sorry.