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,206
  • 12
  • 26
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
  • 735
  • 4
  • 20
  • 36
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
  • 31,534
  • 6
  • 35
  • 61