Slider: Response required

Hello! I designed my slider to not force end routine until they press the space bar to get to the next screen. I was wondering if there was a way to require a response on the slider? I saw there was a way to do it with a button to press condition, however, I wanted to simply just have the user press space once they make their selection.


Slider has a method called getRating() which returns the currently selected rating of the slider component. If no rating is slected it returns None.
So if getRating() returns something other than None you know that a selection was made.
Your keyboard component has an attribute called start (in the keyboard component settings) that defines when it should start listening to keyboard input. Out of the box it is set to time 0 (which means it starts on second 0 of the current routine).
You can change this attribute to be a condition and set the condition to slider.getRating() != None so that it only starts listening to keyboard inputs when the slider components rating is something different from None:

This should do the trick.

Hello, I am having a similar problem. I am trying to not let the routine end before a response is given with the following code in each frame component:

if slider_lottery.markerPos:
    sliderStarted = True

rating = slider_lottery.getRating()

if rating is not None or rating == 0.0:
    if 'space' in space_lottery.keys:
        continueRoutine = False

It works (almost) fine. My slider ranges from 0-10 and it´s not working if the slider is not moved and initially zero picked. I guess that Python Code assumes that the slider.pos is still empty when the value zero is picked? Is there a way to solve this issue?

Have you set a starting value for the slider in it’s settings?
Maybe you could try removing it, so that participants need to actively choose a value.


What are you trying to achieve? The description

is too vague to deduce what you want to achieve.

The solution described above by @umb does or doesn’t do what you want? The participant can’t end the trial unless he or she gives a rating and presses space. Any space before the rating will be ignored.

Note that a rating of 0.0 is not None. So or rating == 0.0 is obsolete.

Best wishes Jens

1 Like

Hello Jens,

I have a slider where participants should be forced to give an answer which is already working. They can only end the routine when a value is chosen and space bar used. The slider does not have a starting value which is not solving my current problem. If a value is chosen on the slider the space bar can be pressed and routine ends except for the case that the participant choses 0 initially and does not move the slider. In that case the routine does not end on space bar press.

I am assuming that PsychoPy is assigning a falsy value so that the slider_lottery.getRating appears empty. Could that be the case? And is there a way to solve this?


Here my little toy-experiment.
Slider10.psyexp (11.5 KB)

You can not end the routine without giving a slider-response and you have to press space to end to routine.

Best wishes Jens

1 Like

Dear Jens,

thank you very much! It is a way easier solution for my issue than the one I was thinking of… works perfect!