Mouse-tracking
Hello everyone,
Is it possible to track the movements of the mouse in online experiments?
What I'm looking to create is a sort of mask so that only the part of the display surrounding the cursor location will be visible.
Basically, I'd like to something like this: https://psyarxiv.com/rsdwg/ but I'm not sure if such a javascript plugin would work in OS? And also, there might be simpler solutions.
Any help would be greatly appreciated :)
Cheers,
Jasper
Comments
So I think I got a solution that actually works quite nicely :)
onmousemove = function(e){vars.x_mouse = e.clientX; vars.y_mouse = e.clientY} if (vars.x_mouse == vars.x_mouse2) { console.log('no x movement'); } else { vars.x_mouse -= 512; //half of display width } if (vars.y_mouse == vars.y_mouse2) { console.log('no y movement'); } else { vars.y_mouse -= 384; //half of display height } vars.x_mouse2 = vars.x_mouse; //for use on the next cycle vars.y_mouse2 = vars.y_mouse;Cheers,
Jasper
Hi Jasper,
Thanks for sharing! That might be quite useful.
Eduard