from pynput import keyboard
def on_press(key):
try:
print('alphanumeric key {0} pressed'.format(
key.char))
except AttributeError:
print('special key {0} pressed'.format(
key))
# Collect events until released文章来源:https://www.toymoban.com/news/detail-437739.html
with keyboard.Listener(
on_press=on_press,
) as listener:
listener.join()文章来源地址https://www.toymoban.com/news/detail-437739.html
到了这里,关于python 键盘监听的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!