Cannot record alphanumeric characters with pynput python

584 Views Asked by At

How to keep track of alphanumeric characters and non special characters (space bar, delete, tab, etc) in pynput. I am using the below code. This code outputs only the special characters and not any other characters input through keyboard.

from pynput.keyboard import Key, Listener

#defining function to print when key is pressed
def on_press(key):
    print('{0} pressed'.format(key))

#defining function to print when key is released
def on_release(key):
    print('{0} release'.format(key))
    if key == Key.esc:
        # Stop listener
        return False

# Collect events until released
with Listener(on_press=on_press, on_release=on_release) as listener:
    listener.join()
0

There are 0 best solutions below