vaneayoung
vaneayoung

Reputation: 363

js: stop mouse movement

it's possible to stop mouse movement in window and allow only in certain box ?

for example, i have a div with width: 200px and height: 200px, to allow only in this div to move mouse.

Thank you.

Upvotes: 0

Views: 879

Answers (1)

gon250
gon250

Reputation: 3545

Javascript can read mouse position but not set it. What I would do for that kind of things is place an element under the mouse and prevent the page element from moving outside of the bounds even.

Also I have seen this link in stackoverflow, maybe it can help you

https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API

Upvotes: 1

Related Questions