Skip to main content
requestPointerLock method

Requests that the pointer be locked to the target element.

Syntax

Element.requestPointerLock();

Parameters

This method has no parameters.

Return value

This method does not return a value.

Standards information

Remarks

A pointerlockchange event will fire if the request was successful; otherwise a pointerlockerror event will fire. The pointer locked element can be accessed by document. pointerLockElement.

When in pointerlock state:

  • The pointer locked element is the target of all mouse / pointer events,
  • The mouse cursor is hidden,
  • All coordinate-related attributes such as screenX or clientX remain constant, and
  • movementX / movementY is not clamped by window or screen boundaries.

See also

Element
exitPointerLock