Don't take key press until slider response is made!

Do you have sliderStarted = False in Begin Routine?

yes, I do have this code chunk in my routine and the issue still occurs.

I forgot to put sliderStarted as the start condition of the keyboard response, now it’s working perfectly fine locally.

But now when running online it always shows a TypeError because the Spacebar is not assigned (TypeError: space_lottery.keys is undefined). This is the code in JavaScript:

    if (slider_lottery.getRating() !== undefined) {
        if (space_lottery.keys.includes('space')) {
            continueRoutine = false;
        }
    }

The issue is that .keys is undefined until a key is pressed. Try

if (slider_lottery.getRating() !== undefined) {
 if (space_lottery.keys) {
        if (space_lottery.keys.includes('space')) {
            continueRoutine = false;
        }
    }
    }

(I prefer to edit the Python code but I think this is correct)

1 Like