With this simple code I want to capture keyboard events for some keys and do specific actions without printing a symbol.
import keyboard
special_keys = [ 'a', 'b', 'c' ]
def on_press(event):
if not event.name.lower() in special_keys:
# Work normal.
keyboard.press(event.name)
return False
# Do other actions instead of printing the symbol.
print('Special key pressed.')
keyboard.on_press(callback=on_press, suppress=True)
keyboard.wait(hotkey='esc', suppress=True)
Why some keys don't work normally, for example shift and control key and how to fix it? Windows 10, Python 3.7, keyboard 0.13.5