# Requiring two inputs to end routine (slider + keyboard)

**URL:** https://discourse.psychopy.org/t/requiring-two-inputs-to-end-routine-slider-keyboard/24905
**Category:** Builder
**Created:** [September 10, 2021, 5:03pm UTC](https://discourse.psychopy.org/t/requiring-two-inputs-to-end-routine-slider-keyboard/24905 "2021-09-10T17:03:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ezaleznik](https://avatars.discourse-cdn.com/v4/letter/e/ed8c4c/32.png) [@ezaleznik](https://discourse.psychopy.org/u/ezaleznik)
#### Post date: [September 10, 2021, 5:03pm UTC](https://discourse.psychopy.org/t/requiring-two-inputs-to-end-routine-slider-keyboard/24905/1 "2021-09-10T17:03:22Z")

</div>

**OS** (e.g. Win10):  
**PsychoPy version** 2021.2.3  
**Standard Standalone? (y/n)** Yes  
**What are you trying to achieve?:**

I want to require participants to click on the slider and then press the spacebar to move to the next trial.

**What did you try to make it work?:**

I’ve set a custom code component under each frame:

```auto
if slider.getRT() != "None" and key_resp.keys == 'space':
    continueRoutine = False

```

The key\_resp is not set to force end of routine, but pressing space will move to the next screen without clicking on the slider. I’ve tried a few combinations to get slider data (getRating(), using \>) but I’m only getting the end of routine on space press only. It should be a simple enough bit of code, but I’m clearly missing something.

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/luke/32/30321_2.png) [@Luke](https://discourse.psychopy.org/u/Luke)
#### Post date: [September 11, 2021, 10:41am UTC](https://discourse.psychopy.org/t/requiring-two-inputs-to-end-routine-slider-keyboard/24905/2 "2021-09-11T10:41:27Z")

</div>

This should do the trick (online and offline):

```auto
if slider.getRT() and key_resp.keys == 'space':
    continueRoutine = False

```

If you are just offline, this works to:

```auto
if slider.getRT() != None and key_resp.keys == 'space':
    continueRoutine = False

```

More detailed information:

Slider-PythonJS is returning “undefined” online not “null” for getRT/getRating

Resulting in slider.getRT() != None ( without quotation marks) converting to (slider.getRT() !== null) in Javascript.

The Problem with “!==” is, no Type Conversion is peformed:

```auto
null === undefined // false
null == undefined // true

```

This means “undefined” is returned but comparison with “null” (“None” conversion from Python to JavaScript) is false.

I think returning undefined is fine in JavaScript. Comparison with “None” in Python should just be avoided, to make the auto-conversion work reliable.

---

<div class="post-metadata">

### Author: ![ezaleznik](https://avatars.discourse-cdn.com/v4/letter/e/ed8c4c/32.png) [@ezaleznik](https://discourse.psychopy.org/u/ezaleznik)
#### Post date: [September 13, 2021, 12:58pm UTC](https://discourse.psychopy.org/t/requiring-two-inputs-to-end-routine-slider-keyboard/24905/3 "2021-09-13T12:58:06Z")

</div>

Worked like a charm, thank you, Luke! I was working from the output where “None” (string) was what was recorded if there was no input, so I didn’t see that it was a null in the code.

Thanks again!
