Web/API/DeviceMotionEvent

From Get docs

This is an experimental technologyCheck 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 SpecificationThe definition of 'DeviceMotionEvent' in that specification. Editor's Draft Initial definition.

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

DeviceMotionEvent

Experimental'

Chrome

Full support 11

Edge

Full support 12

Firefox

Full support 6

IE

No support No

Opera

Full support 15

Safari

Full support 5

WebView Android

Full support ≤37

Chrome Android

Full support 18

Firefox Android

Full support 6

Opera Android

Full support 14

Safari iOS

Full support 4.2

Samsung Internet Android

Full support 1.0

DeviceMotionEvent() constructor

Experimental'Non-standard'

Chrome

Full support 59

Edge

Full support ≤79

Firefox

?

IE

No support No

Opera

?

Safari

?

WebView Android

Full support 59

Chrome Android

Full support 59

Firefox Android

?

Opera Android

?

Safari iOS

?

Samsung Internet Android

Full support 7.0

acceleration

Experimental'

Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 6

IE

No support No

Opera

Full support Yes

Safari

?

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 6

Opera Android

?

Safari iOS

Full support 4.2

Samsung Internet Android

Full support Yes

accelerationIncludingGravity

Experimental'

Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 6

IE

No support No

Opera

Full support Yes

Safari

?

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 6

Opera Android

Full support Yes

Safari iOS

Full support 4.2

Samsung Internet Android

Full support Yes

interval

Experimental'

Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 6

IE

No support No

Opera

Full support Yes

Safari

?

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 6

Opera Android

Full support Yes

Safari iOS

Full support 4.2

Samsung Internet Android

Full support Yes

rotationRate

Experimental'

Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 6

IE

No support No

Opera

Full support Yes

Safari

?

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 6

Opera Android

Full support Yes

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.
Non-standard. Expect poor cross-browser support.'
Non-standard. Expect poor cross-browser support.


See also