Requiring two inputs to end routine (slider + keyboard)

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:

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.

This should do the trick (online and offline):

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

If you are just offline, this works to:

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:

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.

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!