I want to end a trial once a particular key has been held down for 2 seconds.
I have code block in the trial loop and at Begin Routine I reset the clock and key list.
kb.clock.reset()
kb.getKeys(clear = True)
Then Each Frame I do this.
keys=kb.getKeys(['up'], waitRelease=False)
for thisKey in keys:
if thisKey.name=='up':
print(thisKey.tDown)
print(kb.clock.getTime())
if kb.clock.getTime() - thisKey.tDown >2:
continueRoutine=False
But it doesn’t work because thisKey.tDown is off a different base time to kb.clock:
Ah okay, it’s more recent than I thought - I’ve been using what was the dev version but is now released as 2021.2.0. In that case, what are your keyboard settings in Preferences → Hardware?
There is no keyboard settings in Hardware.
There are something like:
-audio library; audio latency mode; audio driver; audio device; parallel ports; and Qmix configuration.
Whoops, sorry, this is me getting too used to dev version again…
Pre-2021.2 the backend is always hardware.keyboard, in which thisKey.tDown is calculated by calling kb.clock.getTime(), so this discrepency is very odd… In 2021.2 it would make sense, as the backend may be ioHub which could be handling time in a different format.
Thank you @Becca Your post contains a lot of useful information that I need now and for my future studies. Just I need to figure out how to adapt them:) Many thanks for sharing!