Controlling Slider in Pavlovia with keyboard

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') {
          if (arrowKeys[0].name === 'right') {
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.

Update on this: I finally managed to get this to work, with the following code snippet:

arrowKeys = psychoJS.eventManager.getKeys({keyList:['left', 'right']});
if (arrowKeys.includes('left')) {
if (arrowKeys.includes('right')) {

Also, in the Begin Routine the value is preset to the default value to make things easier for the subjects, and also to prevent None-values:


The entire (test case) code is viewable here: .


Hey @enniin, thank your very much for your posts. I was struggeling with the same problem.

A quick update:
For me it worked when I removed the “_” in front of the recordRating. The code I am currently running is:

arrowKeys = psychoJS.eventManager.getKeys({keyList:['e', 'o']});
if (arrowKeys.includes('e')) {
if (arrowKeys.includes('o')) {

My slider is named confidence and I use “e” and “o” instead of left right.