from pynput import keyboard
def keyevent(key):
name = key.name if hasattr(key, 'name') else key.char
print(name)
with keyboard.Listener(on_press=keyevent, on_release=keyevent) as listener:
listener.join()
I get:
b # ok when pressing the B key
ctrl_l # ok
alt_l # ok
None # not ok! when doing CTRL + ALT + B , should be : b
ctrl_l # ok
<weird UTF8 char> # not ok! when doing CTRL + B , should be : b
When doing:
I get:
How to solve this and get consistent key names?
I use Windows + Python 3.7.