1# pip3 install pynput
2
3from pynput.keyboard import Key, Listener
4
5
6def show(key):
7
8 pressed_key = str(key).replace("'", "")
9 print(" key: ", pressed_key)
10
11 if key == Key.esc:
12 # Stop listener
13 return False
14
15
16# Listener
17with Listener(on_press=show) as listener:
18 listener.join()
19