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.getKeys(clear = True)
Each Frame I do this.
for thisKey in keys:
if kb.clock.getTime() - thisKey.tDown >2:
But it doesn’t work because
thisKey.tDown is off a different base time to kb.clock:
Anyone know what clock is
thisKey.tDown is running off here?
Or a better way to get the functionality i want?
This depends on what backend you’re using for the keyboard - what happens if you add
I added that in the Each Frame section, but I got an error (pic attached).
Do you think I should define it first?
What version are you using? It may be you’re on a version from before we added that attribute
It’s v2021.1.4. I think it is the latest.
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.
Do you mean ‘Key Bindings’?
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.
I think you should be able to compare
thisKey.rt to get this? see related post here Measuring key lift time relative to stimulus onset
Hope this helps,
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!