boppreh / keyboard

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

Use non-localized virtual keys (MapVirtualKeyW) or let us set/ignore the locale #517

Open Avasam opened 2 years ago

Avasam commented 2 years ago

https://github.com/boppreh/keyboard/blob/master/keyboard/_winkeyboard.py#L393 Non-localized key names would fix a lot of issues. Especially given that: A) Parts of the code wrongly assumes english keys B) There's no way to translate the key names back to english

MapVirtualKeyW function (winuser.h)

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mapvirtualkeyw

To specify a handle to the keyboard layout to use for translating the specified code, use the MapVirtualKeyEx function.

MapVirtualKeyExW function (winuser.h)

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mapvirtualkeyexw

The function translates the codes using the input language and an input locale identifier.