Skip to Content
Platform.Ontology

Pointer Lock

Hides and captures the mouse for games and 3D views.

Does something on your deviceTyping and clipboardPointerWeb browsersWhile you use it

In one line

Can hide your mouse pointer and capture its movement for games or 3D views

Hides and captures the mouse for games and 3D views.

Gives raw relative mouse movement with unlimited range while the cursor is hidden. With unadjustedMovement the site gets unaccelerated input, a small hardware hint.

What it can and can't do

What the user does: You click inside a game or 3D view

It can

  • Hide the pointer and track raw mouse movement
  • Let you turn a camera or view without hitting the screen edge
  • Use unaccelerated mouse input if the site asks for it

It cannot

  • Start without a click, tap or key press
  • Trap you; Esc always gets you out
  • Keep control after you switch tabs or apps
  • Work in Safari on iPhone

How it differs between platforms: Chrome, Firefox, Safari on Mac and Android browsers support it. Safari on iPhone does not.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported372014-08-26None
EdgeSupported132015-11-12None
FirefoxSupported502016-11-15None
SafariSupported10.12017-03-27None
Safari on iPhoneNot supportedNo mouse on iOSNot listedNone
Chrome on AndroidSupported1442026-01-13None
Samsung InternetSupported3.02015-04-10None

How a site asks for it

APIelement.requestPointerLock({unadjustedMovement: true}); movementX, movementY
Browser compat keysapi.Element.requestPointerLock
How access is grantedgesture
What the user seesBrowser shows an on-screen notice and Esc to exit; some platforms prompt on re-lock. Needs a gesture.
Needs a secure context (HTTPS)Yes
Needs a user gestureYes
How long it lastsUntil Esc or unlock
How to take it backPress Escape, leave page
Inside an iframeFrame needs allow-pointer-lock in sandbox

Typical flow

  1. Click on an element
  2. requestPointerLock()
  3. Browser shows exit hint
  4. mousemove events carry movementX/Y

Data you get

What comes back: Relative mouse deltas
Shape: event
How often: per mouse event (about 125 Hz or higher)

FieldTypeUnitRangePrecision
movementX/Yfloatpixelsunbounded1 or fractional

Technical limits

  • Needs a gesture
  • Escape always exits

The story

What it is

A page hides your mouse pointer and reads your raw movement, like in a shooter game.

For you

You click on a game and your mouse pointer disappears. You can turn endlessly with no screen edge stopping you. The browser shows a small note and Escape gives the pointer back.

For makers

First person games, 3D viewers and cloud gaming need unlimited relative mouse movement. Makers can offer console quality aim on the web without installing anything.

Where you see it

TypeExampleApps
gamesA browser shooter hides the pointer and uses raw mouse movement so you can spin the camera freely.Krunker.io, Shell Shockers, Minecraft Classic
gamesA cloud gaming service passes your raw mouse movement to the remote PC so aim feels right.GeForce NOW, Xbox Cloud Gaming
creativeA 3D modeling web app locks the pointer while you orbit around an object.Sketchfab
mapsA 3D globe or map site lets you drag without leaving the screen edge.Google Earth
enterpriseA remote desktop in the browser shows the host's pointer rather than yours.None named
analyticsRaw mouse deltas let a game study aim patterns, which also reveals cheaters.None named

Risks

  • Can hide the cursor
  • Fake click traps

What the platform says

Good uses and abuse

Legitimate uses

  • 3D games and CAD

Known abuse

  • Locking cursor to a scam page

Scores

ScoreValueMeaning
Sensitivity2 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction1 of 5How much the user has to do
Fingerprint bits1Rough identifying entropy, when known

History

  • 2020-08, Chrome 88: unadjustedMovement option ships
  • Keyboard Lock. Can capture keys like Escape and Alt+Tab while the page is full screen

Sources

How well checked: Based on official documentation.

On this page