URL of experiment: https://run.pavlovia.org/arkadiym/oddball_test89/html
Description of the problem: I am attempting to end a loop if participants press “space” and repeat it if they press “r”. I have seen some issues with ending loops listed on this site, but nothing that seems to apply to this case. When participants reach the end of instructions, they are instructed to press spacebar, this works in psychopy, but I get the following error in Pavlovia:
“TypeError: Cannot use ‘in’ operator to search for ‘space’ in undefined.”
I put the following code into “Begin Routine”, “Each Frame”, and “End Routine”:
Python:
if 'space' in key_resp_11.keys:
trials_7.finished = True
Automatic JS translation:
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 (_pj.in_es6("space", key_resp_11.keys)) {
trials_7.finished = true;
}
FYI- my loop is set to 999 reps, and should end only if participants press the “space”. I would love to hear any suggestions for fixing this on Pavlovia.