Element.requestPointerLock()

The Element.requestPointerLock() method lets you asynchronously ask for the pointer to be locked on the given element.

To track the success or failure of the request, it is necessary to listen for the pointerlockchange and pointerlockerror events at the Document level.

Syntax

requestPointerLock()

Parameters

None.

Return value

None (undefined).

Security

Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.

Specifications

Specification
Pointer Lock 2.0
# dom-element-requestpointerlock

Browser compatibility

BCD tables only load in the browser

See also