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.
addEventListener('pointerlockchange', event => { });
onpointerlockchange = event => { };
Event type
A generic Event
.
Examples
Using addEventListener()
:
document.addEventListener('pointerlockchange', (event) => {
console.log('Pointer lock changed');
});
Using the onpointerlockchange
event handler property:
document.onpointerlockchange = (event) => {
console.log('Pointer lock changed');
};
Specifications
Specification |
---|
Pointer Lock 2.0 # pointerlockchange-and-pointerlockerror-events |
Browser compatibility
BCD tables only load in the browser