Detecting when the mouse moves

Does anyone know how to detect when a mouse moves and stop displaying a stimulus once the mouse moves?
I tried setting the stimulus stop to condition: mouse.mouseMoved(), but it doesn’t seem to register and actually stop the stimulus.

What I’m actually trying to do is have the stimulus start in one position (the center), and then move based on the mouse, but I figured it was easiest to have two stimuli components: one that stops when the mouse moves and one that starts as soon as it moves. If anyone knows a better way to do that, that would also be helpful!

You could detect the mouse location at the beginning of the routine and then calculate the offset so that the image starts in the centre.

It looks like you have done the right thing, but for me it throws an error. Adding a call to mouse.getPos() in a code component in the “Begin Routine” tab fixed it. An example is attached below. The first stim ends on a mouse move. The onset of the other stim is determined by the status of the finished stim, e.g., onset condition is text.status == FINISHED.

testMouse.psyexp (8.4 KB)

Thank you, that worked!

Hi

I used the same solution in my own experiment where I want the colour and location of one of three of my stimuli to change after a participant initiates a mouse movement. Everything works in PsychoPy but when I try to run the experiment in PsychoJS the second set of stimuli don’t appear. If I change it so my polygons start/stop after a given time it works so must be a problem with the use of mouse.mouseMoved() . There aren’t any errors flagged in the JS script so difficult to figure out what’s going wrong. Any suggestions would be really appreciated!