URL of experiment: AnkerEffekt [PsychoPy]
Description of the problem: Backspace does not work online
Hello
I have a simple anchor-experiment in which I use the following code to collect the responses from the participants.
Python Begin routine
text.text = ''
event.clearEvents('keyboard')
Python Each frame
keys = event.getKeys()
if len(keys):
if ('backspace' in keys or 'N/A' in keys) and len(text.text):
text.text = text.text[:-1]
elif ('return' in keys or 'num_enter' in keys) and text.text != '':
continueRoutine = False
elif '1' in keys or 'num_1' in keys:
text.text = text.text+'1'
elif '2' in keys or 'num_2' in keys:
text.text = text.text+'2'
elif '3' in keys or 'num_3' in keys:
text.text = text.text+'3'
elif '4' in keys or 'num_4' in keys:
text.text = text.text+'4'
elif '5' in keys or 'num_5' in keys:
text.text = text.text+'5'
elif '6' in keys or 'num_6' in keys:
text.text = text.text+'6'
elif '7' in keys or 'num_7' in keys:
text.text = text.text+'7'
elif '8' in keys or 'num_8' in keys:
text.text = text.text+'8'
elif '9' in keys or 'num_9' in keys:
text.text = text.text+'9'
elif '0' in keys or 'num_0' in keys:
text.text = text.text+'0'
Python End Routine
thisExp.addData("Antwort", text.text)
While this works offline, it does not work online.
PsychoJS Begin routine
text.text = "";
psychoJS.eventManager.clearEvents("keyboard");
PsychoJS Each frame
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);
keys = psychoJS.eventManager.getKeys();
if (keys.length) {
if (((_pj.in_es6("backspace", keys) || _pj.in_es6("N/A", keys)) && text.text.length)) {
text.text = text.text.slice(0, (- 1));
} else {
if (((_pj.in_es6("return", keys) || _pj.in_es6("num_enter", keys)) && (text.text !== ""))) {
continueRoutine = false;
} else {
if ((_pj.in_es6("1", keys) || _pj.in_es6("num_1", keys))) {
text.text = (text.text + "1");
} else {
if ((_pj.in_es6("2", keys) || _pj.in_es6("num_2", keys))) {
text.text = (text.text + "2");
} else {
if ((_pj.in_es6("3", keys) || _pj.in_es6("num_3", keys))) {
text.text = (text.text + "3");
} else {
if ((_pj.in_es6("4", keys) || _pj.in_es6("num_4", keys))) {
text.text = (text.text + "4");
} else {
if ((_pj.in_es6("5", keys) || _pj.in_es6("num_5", keys))) {
text.text = (text.text + "5");
} else {
if ((_pj.in_es6("6", keys) || _pj.in_es6("num_6", keys))) {
text.text = (text.text + "6");
} else {
if ((_pj.in_es6("7", keys) || _pj.in_es6("num_7", keys))) {
text.text = (text.text + "7");
} else {
if ((_pj.in_es6("8", keys) || _pj.in_es6("num_8", keys))) {
text.text = (text.text + "8");
} else {
if ((_pj.in_es6("9", keys) || _pj.in_es6("num_9", keys))) {
text.text = (text.text + "9");
} else {
if ((_pj.in_es6("0", keys) || _pj.in_es6("num_0", keys))) {
text.text = (text.text + "0");
}
}
}
}
}
}
}
}
}
}
}
}
}
PsychoJS End Routine
psychoJS.experiment.addData("Antwort", text.text);
Thanks a lot for your help.
Jens