The devicemotion
event is fired at a regular interval and indicates the amount of physical force of acceleration the device is receiving at that time. It also provides information about the rate of rotation, if available.
Bubbles | No |
---|---|
Cancelable | No |
Interface | DeviceMotionEvent |
Event handler property | Window.ondevicemotion |
Examples
function handleMotionEvent(event) { var x = event.accelerationIncludingGravity.x; var y = event.accelerationIncludingGravity.y; var z = event.accelerationIncludingGravity.z; // Do something awesome. } window.addEventListener("devicemotion", handleMotionEvent, true);
Specifications
Specification | Status |
---|---|
DeviceOrientation Event Specification The definition of 'DeviceMotion event' in that specification. |
Editor's Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
devicemotion event | Chrome Full support Yes | Edge Full support ≤18 | Firefox Full support 6 | IE ? | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 6 | Opera Android No support No | Safari iOS Full support 4.2 | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.