Skip to Content
Platform.Ontology

Accelerometer, LinearAccelerationSensor, GravitySensor

Reads device acceleration, with or without gravity, as a stream.

Asks you firstLocation and motionGeneric Sensor APIWeb browsersWhile you use it

In one line

Can feel how your device moves and rests while the page is open

Reads device acceleration, with or without gravity, as a stream.

Shows how the phone moves and rests: walking cadence, vehicle vibration, on a table or in a pocket. Sensor noise can fingerprint the hardware.

What it can and can't do

What the user does: Nothing in most browsers. Chrome allows it by default unless you changed Motion sensors in site settings

It can

  • Measure movement with or without gravity
  • Spot walking, riding in a vehicle, or lying on a table
  • Move a game or view as you shake or tilt

It cannot

  • Run in Firefox or Safari, which do not support it
  • Show a prompt in Chrome; there is none by default
  • Measure movement while the page is closed
  • Know your location from it

How it differs between platforms: Chrome, Edge and Samsung Internet support it. Safari and Firefox do not.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported672018-05-29None
EdgeSupported792020-01-15None
FirefoxNot supportedDeviceMotion events onlyNot listedNone
SafariNot supportedNot availableNot listedNone
Safari on iPhoneNot supportedNot availableNot listedNone
Chrome on AndroidSupported672018-05-31None
Samsung InternetSupported9.02018-09-15None

How a site asks for it

APInew Accelerometer({frequency, referenceFrame}); new LinearAccelerationSensor(); new GravitySensor()
Permission nameaccelerometer
Permissions policyaccelerometer
Browser compat keysapi.Accelerometer
api.LinearAccelerationSensor
api.GravitySensor
How access is grantedprompt
What the user seesChromium shows no bubble: access follows the Motion sensors site setting (default Allow) plus the Permissions API name. Safari and Firefox do not ship the API.
Needs a secure context (HTTPS)Yes
Needs a user gestureNo
How long it lastsSite setting Allow or Block per origin
How to take it backchrome://settings/content/sensors; Permissions API 'change' event
Inside an iframeCross-origin iframes blocked unless allow="accelerometer"; page must be focused and visible

Typical flow

  1. Check isSecureContext and Permissions Policy
  2. Construct the sensor with {frequency: 60}
  3. sensor.start()
  4. 'reading' events fire; 'error' event on NotAllowedError or NotReadableError

Data you get

What comes back: Sensor readings at the requested frequency
Shape: event
How often: up to 60 Hz (Chrome caps frequency)

FieldTypeUnitRangePrecision
x, y, zfloatm/s2about -78 to 78 hardware limitabout 0.01
frequencyfloatHz1 to 60 (Chrome cap)1 Hz

Technical limits

  • Chrome caps at 60 Hz
  • Stops when the page is hidden
  • Not in Firefox or Safari

The story

What it is

The page reads a live stream of how your device moves and which way is down.

For you

You shake or walk and a web app reacts, for example a step counter or a ball that rolls. On many phones there is no big prompt. Tiny differences in the sensor can also make your device recognizable.

For makers

Makers use it for tilt controls, step counting and gestures. Trackers use sensor noise as a fingerprint, and researchers showed walking patterns and keystrokes can be guessed from it.

Where you see it

TypeExampleApps
gamesA browser racing or maze game lets you steer by tilting your phone.None named
fitnessA web fitness page counts steps or jumps and times your reps.None named
healthA fall detection or walking test page uses motion to check balance.None named
ar-vrA web AR scene keeps a model steady as you move your phone.8th Wall
securityA fraud tool checks for natural motion, since a bot farm phone sits perfectly still.None named
analyticsA fingerprinting script uses sensor noise to recognize a phone across sites.None named

Risks

  • Sensor noise fingerprints devices
  • Can leak typing

What the platform says

Good uses and abuse

Legitimate uses

  • Motion-controlled games
  • Activity recognition PWAs

Known abuse

  • Hardware fingerprinting from calibration error
  • Keystroke inference side channels

Scores

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

History

  • 2018-05, Chrome 67: Generic Sensor API and Accelerometer ship
  • 2019, Firefox n/a: Mozilla and WebKit declined Generic Sensor citing fingerprinting

Sources

How well checked: Based on official documentation.

On this page