• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Motion Sensing Development
2
3## When to Use
4
5An application can call the motion module to identify user actions, for example, whether the user is operating the device screen with the left hand or the right hand.
6
7For details about the APIs, see [Motion API Reference](../../reference/apis-multimodalawareness-kit/js-apis-awareness-motion.md).
8
9## Available APIs
10
11| API                                                      | Description                                  |
12| ------------------------------------------------------------ | -------------------------------------- |
13| on(type:'operatingHandChanged',callback:Callback<OperatingHandStatus>):void; | Subscribes to operating hand change events. This API uses an asynchronous callback to return the result.|
14| off(type: 'operatingHandChanged', callback?: Callback<OperatingHandStatus>): void; | Unsubscribes from operating hand change events.                  |
15| getRecentOperatingHandStatus(): OperatingHandStatus;         | Obtains the latest operating hand status.                |
16
17## Constraints
18
19The device has a touchscreen and supports specific chips.
20
21
22
23## How to Develop
24
25```ts
26import { motion } from '@kit.MultimodalAwarenessKit';
27```
28
291. Subscribe to operating hand change events.
30
31   ```
32   motion.on('operatingHandChanged', (data:motion.OperatingHandStatus) => {
33     console.info('on success' + data);
34   })
35
36   ```
37
382. Unsubscribe from operating hand change events.
39
40   ```
41   motion.off('operatingHandChanged', (data:motion.OperatingHandStatus) => {
42     console.info('off success' + data);
43   })
44
45   ```
46
473. Obtain the latest operating hand status.
48
49   ```
50   let data:motion.OperatingHandStatus = motion.getRecentOperatingHandStatus();
51   console.info('get success' + data);
52   ```
53
54
55