Hello,
I have been unable to get Keyboard.getKeys() to return any key presses, but have found success using Keyboard.waitKeys(). I am worries that I don’t understand how to use .getKeys() and am seeking guidance.
The following minimal code works, and reports on any key presses that I hit:
##################
kb = keyboard.Keyboard()
print('begin')
kb.clock.reset()
keys = kb.waitKeys(maxWait=5, waitRelease=False, clear=True)
for key in keys:
print(key.name, key.rt, key.duration)
##########################
However, this code returns an empty list for keys:
##########################
kb = keyboard.Keyboard()
print('begin')
kb.clock.reset()
tStart = kb.device.clock.getTime()
while kb.device.clock.getTime() - tStart < 5:
keys = kb.getKeys()
for key in keys:
print(key.name, key.rt, key.duration)
#####################
For both cases, I have a Window() that is open. In fact, I needed the Window to exist in order for waitKeys to have any success.
Am I using getKeys incorrectly? I am worried that I am not using the Keyboard class correctly.
Thanks for your time and guidance