Hi all
URL of experiment: Sign in · GitLab
Description of the problem:
I am new to psychopy and to coding as well and put something together from here and there. 5 words are displayed to the participant. Afterwards, they have to write down as many words as they remember. Therefore I created a loop so that they can write the word and after hitting enter, they can write the next word. This happens five times or if the time limit of 30 seconds is reached, it will exit the loop automatically. It works fine in psychopy but in pavlovia, after hitting enter, the word which was just written down flashes for a few milliseconds.
The java code is:
Begin Routine:
respDisplay = “”;
//key logger defaults
last_len = 0
key_list =
if ((trials.thisN === 0)) {
startTime = globalClock.getTime();
}
Each Frame:
//if a new key has been pressed since last time
if(keyResp.keys != undefined && keyResp.keys.length > last_len) {
//increment the key logger length
last_len = keyResp.keys.length
//grab the last key added to the keys list
key_list.push(keyResp.keys.pop())
//check for backspace
if(key_list.indexOf("backspace") != -1) {
key_list.splice(key_list.indexOf("backspace"), 1)
//if we have at least 1 character, remove it
if (key_list.length > 0) {
key_list.pop();
}
}
else
//if enter is pressed then...
if(key_list.indexOf("return") != -1) {
//remove the enter key
key_list.pop();
//and end the trial if we have at least 2 digits
if (key_list.length >= 2) {
continueRoutine = false;
}
}
//create a variable to display
respDisplay = key_list.join("");
}
if (((globalClock.getTime() - startTime) >= 30)) {
trials.finished = true;
continueRoutine = false;
}
End Routine:
psychoJS.experiment.addData(“subjResponse”, respDisplay);
Grateful for every help!
Best, Nicolas