Locks the mouse pointer to its current position and makes it invisible.
requestPointerLock()
allows the mouse to move forever without leaving the screen. Calling requestPointerLock()
locks the values of mouseX, mouseY, pmouseX, and pmouseY. movedX and movedY continue updating and can be used to get the distance the mouse moved since the last frame was drawn. Calling exitPointerLock() resumes updating the mouse system variables.
Note: Most browsers require an input, such as a click, before calling requestPointerLock()
. It’s recommended to call requestPointerLock()
in an event function such as doubleClicked().
Examples
Syntax
requestPointerLock()
Parameters
Related References
doubleClicked
A function that's called once when a mouse button is clicked twice quickly.
exitPointerLock
Exits a pointer lock started with requestPointerLock.
mouseButton
An object that tracks the current state of mouse buttons, showing which buttons are pressed at any given moment.
mouseClicked
A function that's called once after a mouse button is pressed and released.