Function pyhook:按特定键时调用函数(与其他键分开)
我开始使用pyHook是因为我希望在用户按下特定键时调用函数。这是我的代码:Function pyhook:按特定键时调用函数(与其他键分开),function,python-2.7,keystroke,pyhook,Function,Python 2.7,Keystroke,Pyhook,我开始使用pyHook是因为我希望在用户按下特定键时调用函数。这是我的代码: def on_keyboard_event(event): if event.KeyID == 79: # ID 79 = 'o' key next_query() # this is a function I created return True 然而,这意味着每次用户按下“o”键时,函数都会被调用,即使用户只是在写“hello”或“oh!”。
def on_keyboard_event(event):
if event.KeyID == 79: # ID 79 = 'o' key
next_query() # this is a function I created
return True
然而,这意味着每次用户按下“o”键时,函数都会被调用,即使用户只是在写“hello”或“oh!”。
因此,我想知道是否有可能告诉python,我希望它只在单独按下该键时才运行该函数,而只在用户按下“o”而不按下其他键时才运行
提前谢谢