Slider - response need to be made before proceeding

Hi there,

In my experiment, I’m using slider to record responses and participants can go to the next trial by pressing the space bar. I used some code suggested in other posts to prevent participants from skipping responses. The code worked locally but failed online. I was able to use slider to make responses but I couldn’t go to the next trial by pressing the space bar.

The Python code:
if slider.getRating() != None:
if ‘space’ in key_resp_3.getKeys():
continueRoutine=False

The Javascript:
var _pj;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === “string”))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
}
}
}
container[“in_es6”] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
if ((slider.getRating() !== undefined)) {
if (_pj.in_es6(“space”, key_resp_3.getKeys())) {
continueRoutine = false;
}
}

I also added “keys=psychoJS.eventManager.getKeys()” in the Javascript at the beginning of the experiment.

The error seems to be something to do with the “undefined” in Javascript. When I checked the developer tool, there was a series of warning.

Does anyone know how to fix this?

Thanks!

I also tried these code suggested by another post I found, but didn’t work online.

Python code:
if slider.getRating():
if ‘space’ in key_resp_3.getKeys():
continueRoutine=False

JS:
event=psychoJS.eventManager;
var _pj;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === “string”))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
}
}
}
container[“in_es6”] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
if (slider.getRating()) {
if (_pj.in_es6(“space”, key_resp_3.getKeys())) {
continueRoutine = false;
}
}

Hi, you can try setting the Start field of your keyboard component to condition > slider.rating (see image attached). This should mean that the keyboard would only start collecting responses when a rating has been made.

Thank you so much! It works