I’m trying to create a 7-point Likert rating scale in Pavlovia, and I want keyboard left and right arrows to control position of the marker. Accepting and end of routine should happen when space is hit.
I’m trying to make it happen with the following javascript snippet in Each Frame, but no cigar:
try {
arrowKeys = trial_response.getKeys({keyList: ['left', 'right'], waitRelease: false});
if (arrowKeys.length > 0) {
if (arrowKeys[0].name === 'left') {
slider.setRating(slider.getRating()-1);
slider.setMarkerPos(slider.getRating()-1);
}
if (arrowKeys[0].name === 'right') {
slider.setRating(slider.getRating()+1);
slider.setMarkerPos(slider.getRating()+1);
}
}
}
catch (err) {}
Corresponding python code works just fine (offline):
arrowKeys = event.getKeys(keyList=['left','right'])
if arrowKeys:
if 'left' in arrowKeys:
slider.markerPos -= 1
if 'right' in arrowKeys:
slider.markerPos += 1
Any hints on where I’m going wrong? I also tried using the private slider._recordRating() function, but that didn’t work either.