Document: pointerlockchange event

The pointerlockchange event is fired when the pointer is locked/unlocked.

This event is not cancelable.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js

addEventListener("pointerlockchange", (event) => {});

onpointerlockchange = (event) => {};

Event type

A generic Event.

Examples

Using addEventListener():

js

document.addEventListener("pointerlockchange", (event) => {
  console.log("Pointer lock changed");
});

Using the onpointerlockchange event handler property:

js

document.onpointerlockchange = (event) => {
  console.log("Pointer lock changed");
};

Specifications

Specification
Pointer Lock 2.0
# pointerlockchange-and-pointerlockerror-events
Pointer Lock 2.0
# dom-document-onpointerlockchange

Browser compatibility

BCD tables only load in the browser

See also