> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# my.onGyroscopeChange

> Listen for gyroscope data updates.

Use this API to register a listener for gyroscope data updates. Events are delivered only after `my.startGyroscope` has been called, at the frequency set by its `interval` parameter.

## Coordinate System

* **x-axis**: horizontal, from left to right across the screen (rotation = tilting the device forward/backward)
* **y-axis**: vertical, from the bottom to the top of the screen (rotation = tilting the device left/right)
* **z-axis**: perpendicular to the screen, pointing outward (rotation = turning the device on a flat surface)

## Parameters

| Type | Required | Description |
| - | - | - |
| Function listener | Yes | Callback that receives the gyroscope data |

## Listener Callback

| Property | Type | Description |
| - | - | - |
| x | Number | Angular velocity around the x-axis, in rad/s |
| y | Number | Angular velocity around the y-axis, in rad/s |
| z | Number | Angular velocity around the z-axis, in rad/s |
| timestamp | Number | Time the data was recorded, in nanoseconds |

## Code Example

```javascript theme={null}
Page({
  onLoad() {
    this.onGyro = (res) => {
      this.setData({ x: res.x, y: res.y, z: res.z });
    };
    my.startGyroscope({ interval: 'game' });
    my.onGyroscopeChange(this.onGyro);
  },
  onUnload() {
    my.offGyroscopeChange(this.onGyro);
    my.stopGyroscope();
  }
});
```

## Related APIs

> [card] [my.startGyroscope](https://docs.rebellapp.com/jsapi/device/gyroscope/my.startGyroscope.md)
>
> Start the gyroscope

> [card] [my.offGyroscopeChange](https://docs.rebellapp.com/jsapi/device/gyroscope/my.offGyroscopeChange.md)
>
> Remove gyroscope listeners


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.