Code for making sure participants respond before moving on

URL of experiment:

Description of the problem:

Hi, I am designing a trust game on psychopy and in the second part of my experiment there are 4 sliders to be presented on each screen together. I tried using the code below to make sure participants can’t press space and go to the next trial until they have responded on all 4 sliders:

slider proceed

from psychopy import event

def has_slider_been_clicked(slider):
return slider.getRating() is not None

sliders = [slider1, slider2, slider3, slider4]
number_of_sliders_clicked = [has_slider_been_clicked(slider) for slider in sliders].count(True)

space_key_pressed = len(event.getKeys([“space”])) > 0
can_proceed = number_of_sliders_clicked == 4 and space_key_pressed

if can_proceed:
continueRoutine = False

I entered this code in ‘each frame’ and set it to auto → JS
I also have a text component telling the participants to press ‘space’ to continue once they have responded to all sliders.

The code seems to partially work by preventing moving on to the next trial until participants have responded on all 4 sliders. However, once responded to all sliders, the space key doesn’t work to move to next trial. Is there something I need to correct in the code for this to work?

I hope my question is clear.

Thank you.