psychopy.org | Reference | Downloads | Github

Cumulative Time of Key Press

Hi,

I’m looking to see if this new experiment I am going to build is possible with psychopy.

I have 5 different videos that i will show. how i transition from video to video is dependent on timing. if a child looks away from the screen for a combined 2 seconds we move to the next video, or after a trial duration of 30 seconds, whatever comes first.

We code where the child looks manually, so if the child were to look away, i want to press a key and when they look back i let go. is there a way to code in psychopy that if i press a key for a total of 2 seconds (cumulative, so not 2 seconds in a row, could be 1 second, then 0.5s and then 0.5 s) move to the next video?

Thanks!

Set a variable to t when the key is pressed then 0 if the key isn’t pressed. Do something if t > variable+2 and variable!=0