DeviceMotionEvent: DeviceMotionEvent() constructor
Device Orientation Events
Device Orientation Events
The **`DeviceMotionEvent()`** constructor creates a new DeviceMotionEvent object.
## Syntax
```js-nolint
new DeviceMotionEvent(type)
new DeviceMotionEvent(type, options)
```
### Parameters
- `type`
- : A string with the name of the event.
It is case-sensitive and browsers always set it to `devicemotion`.
- `options`
- : An object that, _in addition of the properties defined in Event()_, can have the following properties:
- `acceleration`
- : A DeviceMotionEventAcceleration object giving the acceleration of the device on the three axis X, Y and Z. Acceleration is expressed in [m/s²](https://en.wikipedia.org/wiki/Meter_per_second_squared). If not specified, every properties in the object will be `null`.
- `accelerationIncludingGravity`
- : A DeviceMotionEventAcceleration 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/s²](https://en.wikipedia.org/wiki/Meter_per_second_squared). If not specified, every properties in the object will be `null`.
- `rotationRate`
- : A DeviceMotionEventRotationRate object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma. Rotation rate is express in degrees per seconds. If not specified, every properties in the object will be `null`.
- `interval`
- : A number representing the interval of time, in milliseconds, at which data is obtained from the device. It defaults to `0`.
### Return value
A new DeviceMotionEvent object.
## Specifications
## Browser compatibility
Cite this
"DeviceMotionEvent: DeviceMotionEvent() constructor". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy