Hi, I am designing an experiment where participants are required to enter two key responses to complete a trial. (sequence of key presses does not matter and both keys must be correct). This is the code I am using to record data.
The trial would not end after participants have input two responses, it only proceeds after the duration for the keyboard component I have set.
The experiment would close itself if there is no responses after the set duration. I would like it to proceed to the next trial instead in this case.
I have no experience in coding at all but I dont think I can implement two key responses just using builder. I appreciate any help I can get.
Thank you, i will try that out. I found a workaround with the builder where i only store data of the first key press while the second key press will end the routine. However, participants would then have to press the first key first, if not it will end the routine without logging the other key press. With your solution, I can implement it properly now.
Everything is working as intended now except that the data produced set all the responses as false (resp.corr = 0) despite routines being correct. Here are some screenshots.
ok, the problem is that you compare resp.keys to the strings corrAns1 and corrAns2. resp.keys is however s, right, down, up, left or right. I used just ‘1’ and ‘2’ as an example. You need to change the if-else construction to
if resp.keys == [str(corrAns1), str(corrAns2)] or resp.keys == [str(corrAns2), str(corrAns1)]:
resp.corr = 1
else:
resp.corr = 0