boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.77k stars 433 forks source link

Hotkey "ctrl + alt + h" is activated but keeps ALT pressed after pressing "right ctrl + alt gr +h" #512

Open lfkpoa opened 2 years ago

lfkpoa commented 2 years ago

Hi,

I'm running Python 3.8.5 on Windows 10 using Anaconda.

When adding the hotkey "ctrl + alt + h", it works fine when pressing the left alt with left ctrl or right ctrl. But when I use "alt gr" key with "right ctrl", the ALT key stays pressed afterwards.

Steps to reproduce:

>>>import keyboard as k
>>>k.add_hotkey('ctrl + alt + h', print, args=['pressed'], suppress=False)

After pressing left ctrl + left alt + h:

>>>print(k.is_pressed('alt gr'), k.is_pressed('alt'), k.is_pressed('ctrl'), k.is_pressed('h'))
False False False False

After pressing right ctrl + alt gr + h:

>>>print(k.is_pressed('alt gr'), k.is_pressed('alt'), k.is_pressed('ctrl'), k.is_pressed('h'))
False True False False

If I press left ctrl + left alt + h again then it releases the alt key.

If I start pressing by "alt gr" the hotkey is not activated, but if I start pressing with "alt" then the hotkey is activated: alt + ctrl + h => ok alt + right ctrl + h => ok ctrl + alt + h => ok ctrl + alt gr + h => ok right ctrl + alt + h => ok right ctrl + alt gr + h => activated but does not release alt key alt gr + ctrl + h => not activated alt gr + right ctrl + h => not activated

Thank you!