I’m trying to modify my code so that I can record multiple response times. I know that the builder does this automatically, but I have a certain time restraints coded so that the trial ends at 2s if the participant responds before 2s. I have the correct code for recording multiple keys, but I need one for recording multiple response times.
I tried to modify the code below by using the same one that I have for multiple keys (for key in keys) to one for multiple RTs (for t in ts, etc.). This did not work. Is there a way that I can record multiple RTs and have them automatically separated by a comma in Excel?
The current code is below.
'
if t >= 2.0 and end_at_2s:
continueRoutine = False
elif t >= 4.0: # all trials end at this stage
continueRoutine = False
otherwise, check for a new keypress:
keys = event.getKeys()
if keys: # if at least one key exists in the list,
if ‘escape’ in keys: # now need to check for the quit key ourselves
core.quit()
elif t < 2.0: # just remember this for later
if not end_at_2s:
thisExp.addData('RT_A', t)
end_at_2s = True
for all key presses:
for key in keys:
keys_pressed = keys_pressed + key # concatenate multiple keys
thisExp.addData('answer', keys_pressed) # update the data
else: # we have a keypress between 2 and 4 s
thisExp.addData('RT_A', t)
thisExp.addData('answer', keys)
continueRoutine = False'