我有一个等待按键并将它们记录在控制台中的脚本:
from pynput.keyboard import Key, Listener
def on_press(key):
print('{0} pressed'.format(
key))
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()
系统本身可以工作,但是,当按住某个键时,它会产生以下结果:
Key.space pressed
Key.space pressed
Key.space pressed
Key.space pressed
Key.space pressed
Key.space pressed
Key.space pressed
Key.space pressed
Key.space pressed
如何使线程暂停,直到释放键?
噜噜哒
犯罪嫌疑人X
相关分类