Hey all! I’m trying to make the slider in PsychoPy only have a value if there is any input. My current code for the slider routine is as follows:
EXPERIMENT_SLIDER_ROUTINE
CUSTOM CODE
Begin Routine
event.clearEvents('keyboard')
exampleSlider.markerPos = random.randint(1, 15)
Each Frame
keys = event.getKeys()
if len(keys):
if 'left' in keys:
exampleSlider.markerPos = exampleSlider.markerPos - 1
elif 'right' in keys:
exampleSlider.markerPos = exampleSlider.markerPos + 1
End Routine
thisExp.addData("exampleSliderRating", exampleSlider.markerPos)
As the slider is initially assigned a value, I was thinking of overwriting the value if key(len) < 1. But, this doesn’t seem to work.
Another option I thought of was to track key presses in a separate custom variable, and then if the length of that variable after the slider routine is still 0, reassign markerPos to be “NA”
This way it would be identifiable, and not a random number.
If you know of a solution, I’d be delighted!
Please and thank you