Using version (2023.2.3).
In my experiment, after watching a video stimulus participants are asked to replicate the position of a number of objects on a blank canvas. Initially, I used a spacebar keyboard response to end routine and move onto the next. However, I would like to add in extra step asking if the participant is finished with their choices before moving on (in case they pressed spacebar by accident, for example).
The plan is to press space bar > display a message like ‘Are you finished, left arrow for no, right arrow for yes’ > if left, remove text component and remain on routine, if right, end routine and go to next routine.
To achieve this, so far, I have set the text component to start on a condition (spaceisPressed) and stop on a condition (leftisPressed), and the following lines of code.
In Begin Routine
spaceisPressed = False
leftisPressed = False
event.clearEvents() #as spacebar is pressed in the previous routine and I couldn't press it again.
In Each Frame
keys = event.getKeys()
if 'space' in keys:
spaceisPressed = True
if 'left' in keys:
leftisPressed = True
So far this achieved what I want (text appears after ‘space’ and disappears after ‘left’) but I can’t complete it more than once, i.e., the participant can’t press space again to display the text.
I have tried adding ’ event.clearEvents() ’ at the end of the Each Frame code, but this didn’t help.
I have tried adding ‘leftisPressed = False ’ after ‘if ‘space’ in keys:’ and ’ spaceisPressed = False ’ after if ‘left’ in keys :’, but these didn’t make a difference.
I have tried setting the data tab of the keyboard component to last key, and all keys (instead of first key), this still doesn’t help. I also changed the keyboard component to set every repeat, but I didn’t think this would work.
I’m not very experienced in coding, so not sure if I’m missing something fairly obvious. Any help appreciated
Thanks,
Aimee