Ok, so finally I managed to find a solution, mostly thanks to this post: End routine after TWO key presses
I adapted @Oli’s code component:
theseKeys = key_resp_1.getKeys(('space','r'), waitRelease=False)
if theseKeys:
if "escape" in theseKeys:
endExpNow = True
else:
thisResp.append(theseKeys)
if len(thisResp) ==2:
continueRoutine = False
And of course, don’t forget to create an empty list at the beginning of the trial:
thisResp = []
It works perfectly!