| Reference | Downloads | Github

Setting mouse position online



Hi all,

I’m trying to get the mouse cursor to return to the centre of the screen after each loop in my online experiment. Offline / locally, I’ve used the following in a (Builder) code component to achieve this:

mouse = event.Mouse()
mouse.setPos((0, 0))

but this doesn’t seem to work online. I get the error:

  • TypeError: Cannot read property ‘Mouse’ of undefined

Any guidance would be appreciated!

How to put mouse in the center of the screen in online experiment

Hi @Jamie, yes if you would want to create a mouse object in JavaScript, you would have to add something like the following:

mouse = new core.Mouse({
    win: psychoJS.window,

The thing is, I do not see anywhere in the PsychJS code that allows you to reset the mouse position. I will add this as an issue on GitHub - see:


My sense (after a quick google) is that this isn’t possible in JS, and could be a nightmare if it were (advertisers stealing your mouse to “encourage” clicking on particular buttons).

While we try to mimic the Python engine as much as possible some things will never be quite the same in browser studies.


Thanks Jon, will close the issue on GitHub