# Using Motion and Direction Sensors The **Web** component can be connected to motion and orientation sensors through standard W3C APIs. When using the acceleration, gyroscope, and device motion event APIs, you need to declare the corresponding sensor permissions in the configuration file. - Add the acceleration permission in the **module.json5** file before using the acceleration and device motion event APIs. ``` "requestPermissions":[ { "name" : "ohos.permission.ACCELEROMETER" } ] ``` - Add the gyroscope permission to the **module.json5** file before using the gyroscope APIs. ``` "requestPermissions":[ { "name" : "ohos.permission.GYROSCOPE" } ] ``` For details about how to add sensor permissions, see [Declaring Permissions in the Configuration File](../security/AccessToken/declare-permissions.md). When connecting the **Web** component to the motion and orientation sensors, configure **onPermissionRequest()** to receive permission request notifications. You can obtain the motion and orientation sensors by calling the following standard W3C APIs in JavaScript. | API | Name | Supported| Description | | ------------------------- | ------------ | -------- | ------------------ | | Accelerometer | Acceleration | Yes | - | | Gyroscope | Gyroscope | Yes | - | | AbsoluteOrientationSensor | Absolute orientation | Yes | - | | RelativeOrientationSensor | Relative orientation | No | Does not support by sensor data.| | DeviceMotionEvent | Device motion event| Yes | - | | DeviceOrientationEvent | Device orientation event| Yes | Obtains the absolute orientation.| **RelativeOrientationSensor()** is not configured since it is not supported. Therefore, this API cannot be used to listen for the relative orientation data of the device. Click buttons on the **index.html** page to listen for corresponding data. The example code is as follows: - Code on the application side: ```ts import { webview } from '@kit.ArkWeb'; import { abilityAccessCtrl, PermissionRequestResult } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; @Entry @Component struct WebComponent { controller: webview.WebviewController = new webview.WebviewController() aboutToAppear() { // Enable web frontend page debugging. webview.WebviewController.setWebDebuggingAccess(true); // Create an **AtManager** instance, which is used for application access control. let atManager = abilityAccessCtrl.createAtManager(); try { atManager.requestPermissionsFromUser(getContext(this), ['ohos.permission.ACCELEROMETER', 'ohos.permission.GYROSCOPE'] , (err: BusinessError, data: PermissionRequestResult) => { console.info('data:' + JSON.stringify(data)); console.info('data permissions:' + data.permissions); console.info('data authResults:' + data.authResults); }) } catch (error) { console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); } } build() { Column() { Web({ src: $rawfile('index.html'), controller: this.controller }) .onPermissionRequest((event) => { if (event) { AlertDialog.show({ title: 'title', message: 'text', primaryButton: { value: 'deny', action: () => { event.request.deny(); } }, secondaryButton: { value: 'onConfirm', action: () => { event.request.grant(event.request.getAccessibleResource()); } }, autoCancel: false, cancel: () => { event.request.deny(); } }) } }) } } } ``` - Code of the **index.html** page: ```html