Element.requestPointerLock() asynchronously asks the browser to lock the pointer on that element (MDN). Listen on document for pointerlockchange and pointerlockerror.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call el.requestPointerLock. Start with this line.
JavaScript
element.requestPointerLock(options?)
Call
What it does
element.requestPointerLock(options?)
Primary signature.
el.requestPointerLock(...)
Call with the arguments your case needs.
Built into the browser. Call requestPointerLock(...) on an Element — no import required.
Library declarations
JavaScript
element.requestPointerLock(options?)
Parameters
Parameter
Description
User gesture
Required. Transient activation (MDN)
Active document
Required. Target must be in an active document
unadjustedMovement
Optional. Raw mouse input (no OS acceleration)
Return Value
Return Value
Description
*
Promise<void> (MDN Promise version)
JavaScript Examples
Example 1 — Lock on Click
MDN pattern: request lock from a canvas click and await the Promise.
Listen on document. MDN: track success/failure at Document level.
Change. Fires on lock and unlock — check pointerLockElement.
Error. Fires when the request fails; pointer stays unlocked.
Request on click. Gesture improves success odds.
Compatibility
Browser Support
Element.requestPointerLock() is part of the Pointer Lock API. MDN marks it Limited availability (not Baseline). It is not Deprecated, Experimental, or Non-standard — still feature-detect in production.
✓ Limited availability · Not Baseline
Element.requestPointerLock()
Ask the browser to lock the pointer on an element. Requires a user gesture; confirm with Document events.
LimitedFeature-detect required
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
requestPointerLock()Limited
Bottom line: Support mirrors Pointer Lock. Always feature-detect, require a click, and pair with pointerlockchange / pointerlockerror.
Frequently Asked Questions
It asynchronously asks the browser to lock the pointer on the given element (MDN). Track success with pointerlockchange and failure with pointerlockerror on document.
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) — feature-detect before relying on it.
MDN documents a Promise that resolves with undefined on success. Some browsers still communicate mainly via pointerlockchange / pointerlockerror — listen for both.
Yes. MDN: transient user activation is required. Call it from a click or other gesture on an active document.
An optional option that disables OS mouse acceleration and uses raw input (MDN). Set { unadjustedMovement: true } for FPS-style camera control.
Press Esc (default unlock gesture) or call document.exitPointerLock(). Listen for pointerlockchange and check document.pointerLockElement.