0

It will be very good if you help me do this guys ! thanks a million in advance

//Something like this I am thingking

$(document).on('mousedown',function(){
    //code that prevents cursor leaving a page
});
Teja
  • 1,236
  • 12
  • 27
Normurod
  • 73
  • 1
  • 1
  • 9

2 Answers2

1

There is a pointer lock API that should do what you are looking for using canvas.requestPointerLock || canvas.mozRequestPointerLock

There is a demo here

Check out the docs

Tony
  • 734
  • 4
  • 19
  • 37
0

I'm not sure it is possible to prevent mouse move.

But, an approach would be to track mouse x/y position and alert user when he's going off the page.

Look this SO answer about mouse tracking.

Community
  • 1
  • 1
Louys Patrice Bessette
  • 33,375
  • 6
  • 36
  • 64