Sensors & Location

Device Orientation & Motion

Probing…

Device Orientation & Motion is a web platform capability in the Sensors & Location category. Tilt, rotation and acceleration events from the device. Supported in Chromium 7+, Firefox 6+, and Safari 4.2+. Requires a secure context (HTTPS or localhost) and a user gesture such as a click or tap.

Secure contextUser gesture

Try it

Loading demo…

Code

// iOS needs an explicit, user-gesture permission request
if (typeof DeviceOrientationEvent.requestPermission === 'function') {
  const state = await DeviceOrientationEvent.requestPermission()
  if (state !== 'granted') return
}

window.addEventListener('deviceorientation', e => {
  console.log(e.alpha, e.beta, e.gamma)
})

Browser support

Chromium
7
Firefox
6
Safari
4.2

Frequently asked questions

Which browsers support Device Orientation & Motion?

Supported in Chromium 7+, Firefox 6+, and Safari 4.2+.

Does Device Orientation & Motion require HTTPS?

Yes. Device Orientation & Motion needs a secure context, so it only works over HTTPS (or on localhost during development).

What is Device Orientation & Motion used for?

Tilt, rotation and acceleration events from the device.

Can I try Device Orientation & Motion in my browser?

Yes. shwcs.net runs a live Device Orientation & Motion demo that probes your current browser and lets you try the API. Everything runs locally — nothing is sent anywhere.

MDN reference ↗ Specification ↗