Window: devicemotion event

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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
devicemotion event
Experimental
Chrome Full support YesEdge Full support YesFirefox Full support 6IE ? Opera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 6Opera Android No support NoSafari iOS Full support 4.2Samsung 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

Document Tags and Contributors

Tags: 
Last updated by: chrisdavidmills,