DeviceMotionEvent

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The DeviceMotionEvent provides web developers with information about the speed of changes for the device's position and orientation.

Warning: Currently, Firefox and Chrome do not handle the coordinates the same way. Take care about this while using them.

Constructor

DeviceMotionEvent.DeviceMotionEvent()
Creates a new DeviceMotionEvent.

Properties

DeviceMotionEvent.accelerationRead only
An object giving the acceleration of the device on the three axis X, Y and Z. Acceleration is expressed in m/s2.
DeviceMotionEvent.accelerationIncludingGravityRead only
An object giving the acceleration of the device on the three axis X, Y and Z with the effect of gravity. Acceleration is expressed in m/s2.
DeviceMotionEvent.rotationRateRead only
An object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma. Rotation rate is expressed in degrees per seconds.
DeviceMotionEvent.intervalRead only
A number representing the interval of time, in milliseconds, at which data is obtained from the device.

Example

window.addEventListener('devicemotion', function(event) {
  console.log(event.acceleration.x + ' m/s2');
});

Specifications

Specification Status Comment
DeviceOrientation Event Specification
The definition of 'DeviceMotionEvent' in that specification.
Editor's Draft Initial definition.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
DeviceMotionEvent
Experimental
Chrome Full support 11Edge Full support ≤18Firefox Full support 6IE No support NoOpera Full support 15Safari Full support 5WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 6Opera Android Full support 14Safari iOS Full support 4.2Samsung Internet Android Full support 1.0
DeviceMotionEvent() constructor
ExperimentalNon-standard
Chrome Full support 59Edge Full support ≤79Firefox ? IE No support NoOpera ? Safari ? WebView Android Full support 59Chrome Android Full support 59Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android Full support 7.0
acceleration
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support 6IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android ? Safari iOS Full support 4.2Samsung Internet Android Full support Yes
accelerationIncludingGravity
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support 6IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support 4.2Samsung Internet Android Full support Yes
interval
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support 6IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari iOS Full support 4.2Samsung Internet Android Full support Yes
rotationRate
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support 6IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 6Opera Android Full support YesSafari 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.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.

See also