Is there a way to move an object continuously across the screen while holding down a key that will also work online on Pavlovia?
At the moment I have the following code which requires that you keep pressing the key - it won’t keep moving the object if you hold down the key. In my task the participant will be reporting the location of an object positioned around a circle. ‘obj1posX’ and ‘obj1posY’ are the position variables set in the task builder to refresh each frame.
I have been able to get this working using pyglet but cannot use that on Pavlovia.
keys = event.getKeys()
if keys:
if 'left' in keys:
deg = deg + 1
obj1posX = Eccentricity * cos(math.radians(deg))
obj1posY = Eccentricity * sin(math.radians(deg))
if 'right' in keys:
deg = deg -1
obj1posX = Eccentricity * cos(math.radians(deg))
obj1posY = Eccentricity * sin(math.radians(deg))
Thanks for sharing this demo! I agree that a mouse seems like a good alternative.
Ideally, I would want to use the keys though because I am trying to replicate an offline experiment that was built in Matlab.
If it’s just two keys, then I’d definitely go with the left and right mouse button. You wouldn’t need to care about the location of the mouse pointer so it would effectively still be a key press.