DeviceOrientation and DeviceMotion events
Tilt and shake data from the phone; iOS asks first, Android Chrome does not.
In one line
Can sense how your phone is tilted and shaken, sometimes only after you allow it
Tilt and shake data from the phone; iOS asks first, Android Chrome does not.
Reveals how the device is held and moved: tilt, walking cadence, vehicle vibration. Research has inferred PINs and keystrokes from tilt patterns, and it hints at device class.
What it can and can't do
What the user does: You open a tilt based page, like a game or AR view, and tap Allow on iPhone
It can
- Measure tilt, turning and shaking while the page is open
- Spot walking steps or vehicle bumps
- Move a view or game as you tilt the phone
It cannot
- Run without your Allow on iPhone Safari 13 and later
- Measure motion while the page is closed or in the background
- Be blocked by default on Android Chrome and Firefox; they allow it unless you turn Motion sensors off
- Know your location; it only senses motion
How it differs between platforms: iPhone Safari asks first. Chrome and Firefox on Android allow it unless you block Motion sensors in site settings.
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 7 | 2010-10-19 | Secure context required from 50; no prompt |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Supported | 6 | 2011-08-16 | No prompt |
| Safari | Supported | 17 | 2023-09-18 | iOS 13 added requestPermission; macOS Safari has no motion sensors |
| Safari on iPhone | Supported | 4.2 | 2010-11-22 | All iOS browsers use WebKit |
| Chrome on Android | Supported | 18 | 2012-06-27 | None |
| Samsung Internet | Supported | 1.0 | 2013-04-27 | None |
How a site asks for it
| API | addEventListener('deviceorientation'|'deviceorientationabsolute'|'devicemotion'); DeviceMotionEvent.requestPermission(), DeviceOrientationEvent.requestPermission() |
| Permission name | accelerometer, gyroscope, magnetometer (Chromium) |
| Permissions policy | accelerometer; gyroscope; magnetometer |
| Browser compat keys | api.DeviceOrientationEventapi.DeviceOrientationEvent.requestPermissionapi.DeviceMotionEventapi.DeviceMotionEvent.requestPermission |
| How access is granted | prompt |
| What the user sees | iOS Safari 13+: system alert asking for Motion and Orientation access, Allow or Don't Allow, after requestPermission(). Chrome and Firefox on Android: no prompt, Motion sensors site setting defaults to Allow. Most desktops: events do not fire. |
| Needs a secure context (HTTPS) | Yes |
| Needs a user gesture | Yes |
| How long it lasts | iOS: remembered for the page session and re-asked after the page process ends; Chrome: site setting Allow or Block per origin |
| How to take it back | iOS: Settings > Safari > Advanced > Motion & Orientation Access (iOS 12.2 global switch); Chrome: Site settings > Motion sensors |
| Inside an iframe | Cross-origin iframes blocked unless allow="accelerometer; gyroscope; magnetometer" (Chrome 76+) |
Typical flow
- iOS: call requestPermission() inside a click handler
- Person taps Allow
- Promise resolves 'granted'
- Add listeners; events fire at about 60 Hz while the tab is visible
Data you get
What comes back: Orientation angles and motion vectors
Shape: event
How often: about 60 Hz maximum
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
alpha | float or null | degrees | 0 to 360 | about 0.1 degree; absolute only on deviceorientationabsolute |
beta | float or null | degrees | -180 to 180 | about 0.1 degree |
gamma | float or null | degrees | -90 to 90 | about 0.1 degree |
acceleration x/y/z | float or null | m/s2 without gravity | about -20 to 20 | about 0.01 |
accelerationIncludingGravity x/y/z | float | m/s2 | about -20 to 20 | about 0.01 |
rotationRate alpha/beta/gamma | float | degrees per second | about -2000 to 2000 | about 0.1 |
interval | float | ms | about 16 at 60 Hz | 1 ms |
Technical limits
- iOS requires a user gesture to request
- No events when the tab is hidden
- Rate about 60 Hz
- Mostly absent on desktops
- Blocked in insecure contexts
The story
What it is
The page feels how you tilt and shake your phone.
For you
You tilt your phone and a 360 photo turns, a marble rolls or a compass needle moves. On iPhone a prompt asks first. On many Android browsers there is no prompt at all.
For makers
Tilt makes web games, AR and photo viewers feel alive without an app. It is also read by trackers, since small sensor quirks are a fingerprint, and research has shown typing can be guessed from motion.
Where you see it
| Type | Example | Apps |
|---|---|---|
| games | A browser racing or balance game lets you steer by tilting your phone. | None named |
| ar-vr | A web AR try on or furniture placement page uses tilt to place a sofa in your room. | IKEA Place web, 8th Wall |
| maps | A web map or compass turns the arrow as you turn your phone. | Google Maps |
| media | A 360 degree video or virtual tour pans as you move your phone. | YouTube 360 |
| fitness | A web workout counter uses shakes and steps to count reps or steps. | None named |
| security | Researchers showed that a page can infer typed PINs from tilt, which is why iPhone asks first. | None named |
| ads | A fraud tool checks for believable motion, because a phone farm or emulator has none. | None named |
Risks
- Can leak typing or PINs
- Often no prompt on Android
What the platform says
- MDN (standards docs): Device orientation events. Describes events that tell pages how a device is tilted and moved, used for compasses, games and 360 views.
Good uses and abuse
Legitimate uses
- Tilt-controlled games
- 360 video and panoramas
- AR on the web
- Shake to undo
Known abuse
- PIN and keystroke inference from motion (published attacks)
- Hardware fingerprinting from sensor calibration (SensorID, 2019)
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 3 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 1 of 5 | How much the user has to do |
| Fingerprint bits | 4 | Rough identifying entropy, when known |
History
- 2016-04, Chrome 50: Orientation and motion events restricted to secure contexts
- 2019-03, Safari on iPhone 12.2: Motion and Orientation access disabled by default behind a setting
- 2019-07, Chrome 76: Cross-origin iframes need accelerometer, gyroscope, magnetometer policy
- 2019-09, Safari on iPhone 13: requestPermission() added; per-site prompt replaces the global setting
Related capabilities
Related
- Accelerometer, LinearAccelerationSensor, GravitySensor. Can feel how your device moves and rests while the page is open
- Gyroscope. Can feel how fast your device turns while the page is open
- Magnetometer. Can sense the magnetic field around your device, like a compass
Sources
- MDN DeviceOrientationEvent.requestPermission
- W3C DeviceOrientation Event Specification
- SensorID: Sensor Calibration Fingerprinting for Smartphones
How well checked: Based on official documentation.