Help implementing a counter and image pop up for each key press

Hello!

The experiment I’m trying to make features an image of a map with numbered turns. The participant is supposed to press the left or right arrows to turn left or right at each numbered turn. There are 32 turns total that the participant has to input within 20 seconds.

I’m trying to have text (like “Turn # _ of 32”) showing the numbered turn that they are on based on how many of the left and right keys they have pressed so far within those 20 seconds, as well as an image pop up with each key press. Currently, both the text for the turn number and the image are set to “set to every repeat.”

However, I think the loop prevents these from being shown from the code I have down because I connected a conditions excel sheet with 32 conditions (for correct answers for each of the 32 turns) with 1 nReps. So what happens is that the turn # text is stuck on turn #1 and the image does not pop up no matter what key is pressed and the 20 seconds ends the routine as wanted.

I’m not sure how to work with loops as I’m a beginner with PsychoPy for my undergrad research lab, so please help!

Screenshot of my Code:

Screenshot of the Loop:

Try replacing line 11 of code_2 with:

elif 'left' in keys or 'right' in keys:

indenting lines 11-13 by a tab.

The JS syntax error is dur to line 7 which is a format that JavaScript can’t understand. However, you can use it if you are only running the experiment offline.

I changed line 11 to your code, but there is still no change (turn # text stuck on turn #1 and the image pops up only once no matter the key input until the 20 seconds are up). :confused: