document.exitPointerLock() is an instance method that asynchronously releases pointer lock (see MDN Document: exitPointerLock()). Learn that it returns undefined, how it pairs with Element.requestPointerLock() and pointerLockElement, why you listen for pointerlockchange / pointerlockerror, and five try-it labs.
01
Kind
Instance method
02
Params
None
03
Returns
undefined
04
Releases
requestPointerLock
05
Track with
pointerlockchange
06
Status
Limited availability
Fundamentals
Introduction
Pointer lock hides the system cursor and feeds raw mouse movement to a page — perfect for first-person games and 3D viewers. You lock with element.requestPointerLock(). To unlock from script, call document.exitPointerLock().
MDN: this method asynchronously releases a pointer lock previously requested through Element.requestPointerLock. Note the split API: request on an element, exit on the document.
💡
Think: unlock the mouse for your game canvas
1) Check document.pointerLockElement 2) If set, call document.exitPointerLock() 3) Listen for pointerlockchange (success path) 4) Also handle Esc — users can unlock without your button
Examples follow MDN Document: exitPointerLock() and practical Pointer Lock patterns. Locking usually needs a user gesture and a supporting desktop browser.
📚 Getting Started
Release lock and observe pointerlockchange.
Example 1 — Exit when locked
Call exitPointerLock() only if a lock target exists.
Document.exitPointerLock() 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.exitPointerLock()
Asynchronously release pointer lock — pair with requestPointerLock, pointerLockElement, and pointerlockchange.
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.exitPointerLock()Limited availability
Bottom line: Call exitPointerLock when pointerLockElement is set. Confirm via pointerlockchange (no Promise). Feature-detect for Limited availability.
Wrap Up
Conclusion
document.exitPointerLock() is the Pointer Lock API’s unlock switch: no parameters, returns undefined, and reports outcomes through events. Guard with pointerLockElement, listen for pointerlockchange, and remember Esc can unlock without your button.
Check document.pointerLockElement before calling exit
Listen for pointerlockchange and pointerlockerror (MDN)
Request lock from a user gesture on the target element
Offer a visible Unlock control plus Esc support
Feature-detect both request and exit methods
❌ Don’t
Expect a Promise from exitPointerLock() (returns undefined)
Assume Baseline support on every device (MDN: Limited availability)
Forget Esc can unlock without your script
Confuse pointer lock with fullscreen or PiP exits
Call request on the document — request belongs on an element (MDN)
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about exitPointerLock()
Unlock asynchronously; confirm with events, not a return value.
5
Core concepts
📝01
Returns
undefined
MDN
🔄02
Async
via events
change / error
📄03
Guard
pointerLockElement
check
⚡04
Pair
requestPointerLock
on element
🛡05
Status
Limited
not Baseline
❓ Frequently Asked Questions
MDN: Document.exitPointerLock() asynchronously releases a pointer lock previously requested through Element.requestPointerLock().
No. MDN does not mark Document.exitPointerLock() as Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline), so feature-detect in production.
None (undefined). MDN: it does not return a Promise. Track success or failure by listening for pointerlockchange and pointerlockerror.
MDN note: exitPointerLock() is called on the document, while requestPointerLock() is called on an element.
Check document.pointerLockElement. If it is non-null, that element is the lock target. It becomes null after a successful unlock.
Yes. Esc (and leaving the page) typically releases the lock. Listen for pointerlockchange so your UI stays in sync.
Did you know?
Fullscreen and PiP exits return Promises, but pointer lock exit does not. That historical quirk is why MDN insists on pointerlockchange / pointerlockerror instead of .then() — different APIs, different success signals.