Reputation: 83
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
});
Upvotes: 0
Views: 139
Reputation: 744
There is a pointer lock API that should do what you are looking for using canvas.requestPointerLock || canvas.mozRequestPointerLock
There is a demo here
Upvotes: 1
Reputation: 33943
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.
Upvotes: 0