| Reference | Downloads | Github

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!