Unwanted jitter in keyboard response
Hi everyone, I'm having an issue with timing of my response collection, your help would be much appreciated!
I've implemented a task using an inline script where keyboard responses are collected. Participants make multiple key presses, which should be collected until a maximum reaction time is reached. However, I can't seem to find a way to implement this without getting jittered max rt's. Below is a simplified version of what I'm trying to do:
my_canvas.show() max_rt = 3000 # maximum reaction time my_keyboard = keyboard(keylist=["1", "2"]) t0 = clock.time() # start tracking duration of trial resp= # for storing keyboard responses each trial while clock.time() - t0 < max_rt: # collect responses until time's up # get keyboard responses key = my_keyboard.get_key(timeout=max_rt) resp.append(key) print("rt given: " + str(clock.time() - t0))
This is implemented in a loop sequence, in which it is preceded by a fixation dot.
Using this code, when there is no key press, the correct max rt is given. However, after some key presses, the while loop continues well past the max rt (I've seen it go over 5600 when set to 3000). It happens even when displaying a blank canvas, and changing backends doesn't make a difference.
I've tried implementing it in other ways to no avail, for example changing the conditions of the while loop:
while True: if clock.time() - t0 >= max_rt: break
Does anyone know why this is happening, and is there another way to implement this in an inline script (it's important in my case to do so)?