AccelerometerLimited availability
The Accelerometer, LinearAccelerationSensor and GravitySensor APIs read the acceleration applied to a device in three dimensions, either including the effect of gravity, without its effect, or only its effect, respectively.
Not yet supported in all major browsers — check the table and provide a fallback.
Browser support
DesktopChrome
1–90Not supported
91+Supportedsince May 25, 2021
Current: 155Edge
12–90Not supported
91+Supportedsince May 27, 2021
Current: 154Firefox
✕Not supportedup to 157
Current: 157Safari
✕Not supportedup to 27
Current: 27MobileChrome Android
18–90Not supported
91+Supportedsince May 25, 2021
Current: 155Firefox Android
✕Not supportedup to 157
Current: 157Safari iOS
✕Not supportedup to 27
Current: 27How to use
Not supported in Firefox, Safari, Firefox Android, Safari iOS. Use feature detection below and provide a fallback (or a polyfill) for those browsers.
Example
Full syntax and examples are on MDN: Accelerometer.
Feature detection
JS · check before using
if ("Accelerometer" in globalThis) {
// Accelerometer is available
} else {
// load a polyfill or use a fallback
}Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (12). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Accelerometer | 67 | 79 | ✕ | ✕ | 67 | ✕ | ✕ |
| Accelerometer.Accelerometer | 67 | 79 | ✕ | ✕ | 67 | ✕ | ✕ |
| Accelerometer.x | 67 | 79 | ✕ | ✕ | 67 | ✕ | ✕ |
| Accelerometer.y | 67 | 79 | ✕ | ✕ | 67 | ✕ | ✕ |
| Accelerometer.z | 67 | 79 | ✕ | ✕ | 67 | ✕ | ✕ |
| GravitySensor | 91 | 91 | ✕ | ✕ | 91 | ✕ | ✕ |
| GravitySensor.GravitySensor | 91 | 91 | ✕ | ✕ | 91 | ✕ | ✕ |
| LinearAccelerationSensor | 67 | 79 | ✕ | ✕ | 67 | ✕ | ✕ |
| LinearAccelerationSensor.LinearAccelerationSensor | 67 | 79 | ✕ | ✕ | 67 | ✕ | ✕ |
| Permissions.permission_accelerometer | 62 | 79 | ✕ | ✕ | 62 | ✕ | ✕ |
| iframe.allow.accelerometer | 66 | 79 | ✕ | ✕ | 66 | ✕ | ✕ |
| http.headers.Permissions-Policy.accelerometer | 88 | 88 | ✕ | ✕ | 88 | ✕ | ✕ |