Document.pointerLockElement
The read-only pointerLockElement
property of the Document
interface provides the element set as the target for mouse events while the pointer is locked. It is null
if lock is pending, pointer is unlocked, or the target is in another document.
Syntax
document.pointerLockElement;
Value
An Element
or null
.
Examples
Determine if a canvas element is currently pointer locked.
if (document.pointerLockElement === canvasElement) { console.log('The pointer lock status is now locked'); // Do something useful in response } else { console.log('The pointer lock status is now unlocked'); // Do something useful in response }
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
pointerLockElement |
37 |
12 |
50
14-50
|
No |
24 |
10.1 |
37 |
37 |
50
14-50
|
24 |
No |
3.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/pointerLockElement