OS (e.g. Win10): Mac OS v12.5.1
PsychoPy version : v2022.2.4
Standard Standalone? (y/n) Y
What are you trying to achieve?:
I am coding for an experiment where I am hoping to end routine after two key presses and to store the key presses as well as the total time spend for the two key presses.
I have tried the following code by @Oli
#beginRoutine Tab
thisResp = [] #make an empty list
#every Frame
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()
else: #add this frame keys to response list
thisResp.append(keys)
if len(thisResp) == 2:
thisExp.addData('response',''.join(thisResp))
thisExp.addData('RT',t)
contineRoutine = False #end routine.
The code does allow me to end the routine at 2 key presses but it doesn’t store any of the data.
The data file looks like above.
So, I am wondering how I should code to store the key presses and the reaction time.