Document: pointerlockerror event
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The pointerlockerror
event is fired when locking the pointer failed (for technical reasons or because the permission was denied).
This event is not cancelable and does not bubble.
Syntax
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("pointerlockerror", (event) => {});
onpointerlockerror = (event) => {};
Event type
A generic Event
.
Examples
Using addEventListener()
:
js
const para = document.querySelector("p");
document.addEventListener("pointerlockerror", (event) => {
console.log("Error locking pointer");
});
Using the onpointerlockerror
event handler property:
js
document.onpointerlockerror = (event) => {
console.log("Error locking pointer");
};
Specifications
Specification |
---|
Pointer Lock 2.0 # pointerlockchange-and-pointerlockerror-events |
Pointer Lock 2.0 # dom-document-onpointerlockerror |
Browser compatibility
BCD tables only load in the browser