Hi all,
I created a self paced reading experiment and everything works fine (now). But one problem appeared several times and I was not able to find a solution yet:
When running the experiment online (on Pavlovia) and pressing accidentally the wrong key during single word presentation (e.g. “j” instead of “space”) the experiment freezes. I guess it has something to do with the code I am using.
In the self pace reading loop I inserted the stimulus Routine with a code component. This is my JS textcode for “Each Frame”:
//Listen for keys
theseKeys = psychoJS.eventManager.getKeys()
n = theseKeys.length
i = 0
//Update stim on spacebar press
while (n > i){
if (theseKeys[i] == "esc"){
psychoJS.quit()
break
} else if (theseKeys[i] == "space"){
psychoJS.experiment.addData("readingRT", clock.getTime())
psychoJS.experiment.addData("sentPos", sentPos)
psychoJS.experiment.addData("word", stimulus)
psychoJS.experiment.addData("keypress", theseKeys[i])
psychoJS.experiment.nextEntry()
sentPos = sentPos + 1
if (sentPos == words.length){
continueRoutine = false
break
}
stimulus = words[sentPos]
i = i + 1
}
}