Requiring two inputs to end routine (slider + keyboard)

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.

1 Like