Web/API/Window/devicemotion event

From Get docs

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 SpecificationThe definition of 'DeviceMotion event' in that specification. Editor's Draft

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

devicemotion event

Experimental'

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.


See also