I'm trying to trigger functions on key presses in python. I'm using the pynput library's listen function, which returns a Keycode object. I've tried casting the object to string but the following code still returns the following output (when pressing the 'a' key):
def on_press(key):
mod = str(key)
print(mod)
print(type(mod))
print(mod=='a')
I get:
'a'
< class 'str'>
False