-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
39 lines (27 loc) · 972 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
title: "Gyroscope: y property"
short-title: "y"
slug: Web/API/Gyroscope/y
page-type: web-api-instance-property
browser-compat: api.Gyroscope.y
---
{{securecontext_header}}{{APIRef("Sensor API")}}
The **`y`** read-only property of the {{domxref("Gyroscope")}} interface returns a number specifying the angular velocity of the device along its y-axis.
## Value
A {{jsxref('Number')}}.
## Examples
The gyroscope is typically read in the {{domxref('Sensor.reading_event', 'reading')}} event callback.
In the example below this occurs sixty times a second.
```js
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();
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}