# Slider: Response required

**URL:** <https://discourse.psychopy.org/t/slider-response-required/34594>\
**Category:** Builder\
**Created:** [April 27, 2023, 8:02pm UTC](https://discourse.psychopy.org/t/slider-response-required/34594 "2023-04-27T20:02:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anne\_Mendoza](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/anne_mendoza/32/37814_2.png) [@Anne\_Mendoza](https://discourse.psychopy.org/u/Anne_Mendoza)\
**Post date:** [April 27, 2023, 8:02pm UTC](https://discourse.psychopy.org/t/slider-response-required/34594/1 "2023-04-27T20:02:24Z")

</div>

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.

TIA

---

<div class="post-metadata">

**Author:** ![umb](https://avatars.discourse-cdn.com/v4/letter/u/cc9497/32.png) [@umb](https://discourse.psychopy.org/u/umb)\
**Post date:** [April 28, 2023, 9:01am UTC](https://discourse.psychopy.org/t/slider-response-required/34594/2 "2023-04-28T09:01:09Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/6/76906507930602726e26bee3a3019b0870f7039c.png)

This should do the trick.

---

<div class="post-metadata">

**Author:** ![tkallies](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tkallies/32/39706_2.png) [@tkallies](https://discourse.psychopy.org/u/tkallies)\
**Post date:** [January 9, 2024, 10:15am UTC](https://discourse.psychopy.org/t/slider-response-required/34594/3 "2024-01-09T10:15:39Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![umb](https://avatars.discourse-cdn.com/v4/letter/u/cc9497/32.png) [@umb](https://discourse.psychopy.org/u/umb)\
**Post date:** [January 9, 2024, 1:32pm UTC](https://discourse.psychopy.org/t/slider-response-required/34594/4 "2024-01-09T13:32:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [January 9, 2024, 2:00pm UTC](https://discourse.psychopy.org/t/slider-response-required/34594/5 "2024-01-09T14:00:01Z")

</div>

Hello

What are you trying to achieve? The description

> [@tkallies](#):
>
> It works (almost) fine

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

---

<div class="post-metadata">

**Author:** ![tkallies](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tkallies/32/39706_2.png) [@tkallies](https://discourse.psychopy.org/u/tkallies)\
**Post date:** [January 10, 2024, 8:50am UTC](https://discourse.psychopy.org/t/slider-response-required/34594/6 "2024-01-10T08:50:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [January 10, 2024, 9:07am UTC](https://discourse.psychopy.org/t/slider-response-required/34594/7 "2024-01-10T09:07:46Z")

</div>

Hello,

Here my little toy-experiment.  
[Slider10.psyexp](https://discourse.psychopy.org/uploads/short-url/2XOpiXLiJcXVmGgeWkKmr74i1fx.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

---

<div class="post-metadata">

**Author:** ![tkallies](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tkallies/32/39706_2.png) [@tkallies](https://discourse.psychopy.org/u/tkallies)\
**Post date:** [January 10, 2024, 1:35pm UTC](https://discourse.psychopy.org/t/slider-response-required/34594/8 "2024-01-10T13:35:28Z")

</div>

Dear Jens,

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