Skip to main content
Version: v3

onDigitalCrown

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Listen to the digital crown rotation event, only one event is allowed to be registered, if multiple registrations will cause the last registered event to fail.

Type

function onDigitalCrown(option: Option): void

Simplified calling method

function onDigitalCrown(callback: (key: Key, degree: Degree) => void): void

Parameters

Option

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
callback(key: Key, degree: Degree) => voidY-Digital crown rotation event callback function2.0

Key

TypeDescription
numberKey name, value reference key name constants, currently only KEY_HOME is supported

Degree

TypeDescription
numberThe rotation angle, positive number is counterclockwise rotation, negative number is clockwise rotation. The value is the angle of rotation, the faster the rotation speed, the larger the absolute value

Constants

Key name constants

ConstantDescriptionAPI_LEVEL
KEY_BACKBACK KEY2.0
KEY_SELECTSELECT KEY2.0
KEY_HOMEHOME KEY2.0
KEY_UPUP KEY2.0
KEY_DOWNSHORTCUT KEY2.0
KEY_SHORTCUTSHORTCUT KEY2.0

Example

import { onDigitalCrown, KEY_HOME } from '@zos/interaction'

onDigitalCrown({
callback: (key, degree) => {
if (key === KEY_HOME) {
console.log(degree)
}
},
})