Document.pointerLockElement is a read-only property that returns the Element set as the target for mouse events while the pointer is locked. It is null if lock is pending, the pointer is unlocked, or the target is in another document (MDN).
Read the notes below before you get or set this property. Prefer feature detection when support is limited.
Syntax
Use document.pointerLockElement. Start with this line.
JavaScript
document.pointerLockElement
Call
What it does
document.pointerLockElement
Primary signature.
Built into the browser. Read or assign document.pointerLockElement — no import required.
Check the property."pointerLockElement" in document.
Check the method. Ensure requestPointerLock exists on elements.
Branch safely. Offer mouse-look only when both are available.
Still may fail. Even with support, a lock request can be denied — listen for pointerlockerror.
Compatibility
Browser Support
Document.pointerLockElement has Limited availability on MDN (not Baseline). Feature-detect and provide a fallback when Pointer Lock is missing or denied.
✓ Limited availability
Document.pointerLockElement
Read-only Element with pointer lock — support varies across browsers.
LimitedFeature-detect first
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
pointerLockElementLimited
Bottom line: Safe to teach and use with detection. Pair with requestPointerLock, exitPointerLock, pointerlockchange, and pointerlockerror.
Frequently Asked Questions
The Element set as the target for mouse events while the pointer is locked in this document, or null if the lock is pending, the pointer is unlocked, or the target is in another document (MDN).
No. MDN marks Document.pointerLockElement as Limited availability (not Baseline). It is not Deprecated, Experimental, or Non-standard. Feature-detect before relying on it.
When pointer lock is not active, while a lock request is still pending, or when the locked element belongs to another document such as an iframe (MDN).
No. The property is read-only. To lock, call element.requestPointerLock(). To unlock, call document.exitPointerLock() or let the user press Esc.
Listen for the pointerlockchange event on document, then read document.pointerLockElement. Use pointerlockerror when a request fails.
fullscreenElement is the element in fullscreen mode. pointerLockElement is the element receiving locked mouse events. Games often use both together.