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!