Document.pointerLockElement is a read-only instance property that returns the Element receiving locked mouse events, or null. Learn MDN’s pointerlockchange pattern, how it parallels fullscreenElement, FPS game workflows, and five examples with try-it labs.
01
Kind
Read-only property
02
Returns
Element | null
03
Active?
!== null
04
Exit
exitPointerLock
05
API
Pointer Lock
06
Status
Limited avail.
Fundamentals
Introduction
Pointer lock lets web apps capture the mouse for first-person games, 3D viewers, and creative tools. While the pointer is locked, the browser hides the cursor and sends continuous movementX / movementY values. Scripts need to know which element owns that lock—that is what document.pointerLockElement provides.
MDN: the read-only property returns the Element set as the target for mouse events while the pointer is locked, or null if the lock is pending, the pointer is unlocked, or the target is in another document.
Examples follow MDN Document: pointerLockElement. Try-it labs read the property safely; request pointer lock from a user click where the browser supports it.
📚 Getting Started
Read the property and detect pointer lock status.
Example 1 — Read When Pointer Lock Is Off
On a normal page, the property is null until lock starts.
JavaScript
console.log(document.pointerLockElement);
// null when pointer is not locked
console.log(document.pointerLockElement === null);
Document.pointerLockElement is marked Limited availability on MDN (not Baseline). Feature-detect before production use. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Limited availability · Not Baseline
Document.pointerLockElement
Read-only Element with pointer lock, or null — Pointer Lock API status check.
LimitedCheck compat
Google ChromeSupported · Desktop
Supported
Mozilla FirefoxSupported in modern versions
Supported
Apple SafariSupported on desktop Safari
Supported
Microsoft EdgeChromium Pointer Lock support
Supported
OperaFollow Chromium behavior
Supported
Internet ExplorerNo Pointer Lock API
Not supported
Document.pointerLockElementLimited availability
Bottom line: Use pointerLockElement !== null to detect lock. Pair with requestPointerLock / exitPointerLock and pointerlockchange / pointerlockerror events.
Wrap Up
Conclusion
Document.pointerLockElement tells you which element (if any) currently owns pointer lock. Check it before calling exitPointerLock(), mirror the pattern of fullscreenElement, and keep UI in sync with pointerlockchange events.
Compare to your target element: === container (MDN)
Start lock only from a user gesture (click / tap)
Listen for pointerlockchange and pointerlockerror
Guard exitPointerLock() with a truthy property check
❌ Don’t
Assign to pointerLockElement expecting to enter lock
Assume pointer lock works on every platform (Limited availability)
Expect parent-document access to iframe lock targets (MDN: null)
Auto-lock without user interaction
Poll the property in a tight loop instead of using events
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about pointerLockElement
Element or null — the pointer lock status property.
5
Core concepts
🎮01
Returns
Element | null
API
✓02
Active
!== null
Check
🚪03
Exit
exitPointerLock
MDN
🎯04
Enter
requestLock
Gesture
🔄05
Events
lockchange
Sync UI
❓ 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 it as Limited availability (not Baseline), but not Deprecated, Experimental, or Non-standard. Feature-detect before relying on pointer lock in production.
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 meaningful assignment. The property is read-only; assigning does not throw even in strict mode — the setter is a no-operation and is ignored (MDN).
Call document.exitPointerLock(), or let the user press Esc. Listen for pointerlockchange and check document.pointerLockElement.
fullscreenElement returns the element in fullscreen mode. pointerLockElement returns the element receiving locked mouse events. Games often use both together.
Did you know?
MDN notes that although pointerLockElement is read-only, assigning to it does not throw—even in strict mode. The setter is ignored. To enter pointer lock, call requestPointerLock() on an element instead.