无法使用pynput python记录字母数字字符

时间:2018-03-31 21:54:59

标签: python listener alphanumeric non-alphanumeric pynput

如何在 pynput 中跟踪字母数字字符非特殊字符(空格键,删除,制表符等)。我使用以下代码。此代码仅输出特殊字符,而不输出通过键盘输入的任何其他字符。

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 个答案:

没有答案