OpenSesame: VAS scale slider bar using keypress
I've come across a few solutions for slider bars using mouse click but I'm trying to set up one using an fMRI button box (keypress) whereby multiple keypresses can move the slider during a set duration (12 sec) and at the end record the final slider position. However, I'm stuck and would appreciate some help.
This is what my canvas looks like:
And this is my code below. It displays the scales but the slider doesn't move (I have gotten it to move by one increment if there's no while loop). Also, I'm using 'm' and 'n' but ideally I'll set these to the keys triggered by our button box.
from openexp.canvas import canvas
from openexp.keyboard import keyboard
my_canvas = canvas(self.experiment)
my_keyboard = keyboard(self.experiment)
resp = "" # Here we store the response
timeout = 5000
score = 0
step_size = .2
start_time = clock.time()
if clock.time() - start_time >= timeout:
response_time = timeout
response = u'timeout'
key, time = my_keyboard.get_key()
if my_keyboard.to_chr(key) == "m":
increment = score*200
my_canvas['slider'].x += increment
elif my_keyboard.to_chr(key) == 'n':
my_canvas['slider'].x -= increment
score = max(0, min(1, score))
The osexp file is also attached.