Limited support Limited browser support. Check compatibility before use.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
67
79
67
HTML attribute
allow (gyroscope)
Experimental
66
79
66
DOM API

The Gyroscope() constructor creates a new Gyroscope object which provides on each reading the angular velocity of the device along all three axes.

67
79
67

The x read-only property of the Gyroscope interface returns a number specifying the angular velocity of the device along its x-axis.

67
79
67

The y read-only property of the Gyroscope interface returns a number specifying the angular velocity of the device along its y-axis.

67
79
67

The z read-only property of the Gyroscope interface returns a number specifying the angular velocity of the device along its z-axis.

67
79
67
permission_gyroscope
Experimental

`gyroscope` permission

51
79
51
Other
gyroscope
Experimental

The HTTP Permissions-Policy header gyroscope directive controls whether the current document is allowed to gather information about the orientation of the device through the Gyroscope interface.

88
88
88
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
let gyroscope = new Gyroscope({ frequency: 60 });

gyroscope.addEventListener("reading", (e) => {
  console.log(`Angular velocity along the X-axis ${gyroscope.x}`);
  console.log(`Angular velocity along the Y-axis ${gyroscope.y}`);
  console.log(`Angular velocity along the Z-axis ${gyroscope.z}`);
});
gyroscope.start();

Use cases

  • Using Gyroscope

    The Gyroscope interface of the Sensor APIs provides on each reading the angular velocity of the device along all three axes.

Cautions

  • Limited browser support. Check compatibility before use.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.