PsychoPy Version: v2023.2.3
Description of the problem:
I am currently trying to solve a problem with a snippet in the code component. Short background: In the study the participants shall start the movie with a certain key, pause with a certain key and continue with a certain key. It works well on the local version but not online in Pavlovia. During the online experiment I cannot press any of the keys that I specified before, so the movie will not pause or continue. It also starts on its own.
I have not worked with JS before and wondered if somebody has an idea what could be going on here or has dealt wiht something similar…
The code snippet in Python [Each Frame] is:
keys = event.getKeys()
for thisKey in keys:
if thisKey == 's':
movie.play()
if thisKey == 'space' and movie.isPlaying:
movie.pause()
if thisKey == 'right' and movie.isPaused:
movie.play()
And the equivalent in JS which I get automatically translated is:
keys = psychoJS.eventManager.getKeys();
for (var thisKey, _pj_c = 0, _pj_a = keys, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
thisKey = _pj_a[_pj_c];
if ((thisKey === "s")) {
movie.play();
}
if (((thisKey === "space") && movie.isPlaying)) {
movie.pause();
}
if (((thisKey === "right") && movie.isPaused)) {
movie.play();
}
}
Reading through other topics makes me wonder whether it has something to do with the event.getKeys() command?
I am very thankful in advance for suggestions!