JavaScript - How to stop mouse movement

前端 未结 3 511
南旧
南旧 2021-01-23 05:56

No jQuery possible.

How to disable / stop mouse movement with JavaScript?

What to do: If the mouse is being moved to, let\'s say,

相关标签:
3条回答
  • 2021-01-23 06:44

    You cannot do this with JavaScript and I dare say you never will be able to.

    If you need to do this for some kind of game element, for example, I recommend that you place a page-element under the mouse and prevent the page-element from moving outside of the bounds even if the mouse does.

    0 讨论(0)
  • 2021-01-23 06:47

    Javascript can read mouse position but not set it. The mouse cursor properties exist outside the HTML Document Object Model and thus are beyond the reach of Javascript. Mouse events however are captured and thus readable / event modification also permissible (mouse hover, mouse over, mouse out, mouse click, dblclick).

    0 讨论(0)
  • 2021-01-23 06:55

    The Pointer Lock API might be what you're looking for

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

    0 讨论(0)
提交回复
热议问题