openharmony 鸿蒙 js-apis-touchevent

2025-06-12 浏览 (1)

@ohos.multimodalInput.touchEvent (Touch Event)

The touchEvent module provides touchscreen events reported by a device. It is inherited from InputEvent.

NOTE

The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { Action,ToolType,SourceType,Touch,TouchEvent } from '@kit.InputKit';

Action

Enumerates touch event types.

System capability: SystemCapability.MultimodalInput.Input.Core

NameValueDescription
CANCEL0Cancellation of touch.
DOWN1Pressing of touch.
MOVE2Moving of touch.
UP3Lifting of touch.

ToolType

Enumerates touch tool types.

System capability: SystemCapability.MultimodalInput.Input.Core

NameValueDescription
FINGER0Finger.
PEN1Stylus.
RUBBER2Eraser.
BRUSH3Brush.
PENCIL4Pencil.
AIRBRUSH5Air brush.
MOUSE6Mouse.
LENS7Lens.

SourceType

Enumerates touch source types.

System capability: SystemCapability.MultimodalInput.Input.Core

NameValueDescription
TOUCH_SCREEN0Touchscreen.
PEN1Stylus.
TOUCH_PAD2Touchpad.

FixedMode19+

Enumerates coordinate correction modes. This API takes effect only for mobile phones.

System capability: SystemCapability.MultimodalInput.Input.Core

NameValueDescription
NONE0Normal mode.
AUTO1One-handed mode.

Touch

Defines the touch point information.

System capability: SystemCapability.MultimodalInput.Input.Core

NameTypeReadableWritableDescription
idnumberYesNoTouch event ID.
pressedTimenumberYesNoPress timestamp, in μs.
screenXnumberYesNoX coordinate of the touch position on the screen.
screenYnumberYesNoY coordinate of the touch position on the screen.
windowXnumberYesNoX coordinate of the touch position in the window.
windowYnumberYesNoY coordinate of the touch position in the window.
pressurenumberYesNoPressure value. The value range is [0.0, 1.0]. The value 0.0 indicates that the pressure is not supported.
widthnumberYesNoWidth of the touch area.
heightnumberYesNoHeight of the touch area.
tiltXnumberYesNoAngle relative to the YZ plane. The value range is [-90, 90]. A positive value indicates a rightward tilt.
tiltYnumberYesNoAngle relative to the XZ plane. The value range is [-90, 90]. A positive value indicates a downward tilt.
toolXnumberYesNoX coordinate of the center point of the tool area.
toolYnumberYesNoY coordinate of the center point of the tool area.
toolWidthnumberYesNoWidth of the tool area.
toolHeightnumberYesNoHeight of the tool area.
rawXnumberYesNoX coordinate of the input device.
rawYnumberYesNoY coordinate of the input device.
toolTypeToolTypeYesNoTool type.
fixedDisplayX19+numberYesNoscreenX correction value in one-hand mode.
NOTE: This API takes effect only for mobile phones.
fixedDisplayY19+numberYesNoscreenY correction value in one-hand mode.
This API takes effect only for mobile phones.

TouchEvent

Defines a touch event.

System capability: SystemCapability.MultimodalInput.Input.Core

NameTypeReadableWritableDescription
actionActionYesNoTouch event type.
touchTouchYesNoCurrent touch point.
touchesTouch[]YesNoAll touch points.
sourceTypeSourceTypeYesNoEnumerates touch source types.
fixedMode19+FixedModeYesYesCoordinate correction mode.
This API takes effect only for mobile phones.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Input Kit

harmony 鸿蒙Input_DeviceListener

harmony 鸿蒙Input_InterceptorEventCallback

harmony 鸿蒙Input_AxisEvent

harmony 鸿蒙Input_DeviceInfo

harmony 鸿蒙Input_DeviceListener

harmony 鸿蒙Input_Hotkey

harmony 鸿蒙Input_InterceptorEventCallback

harmony 鸿蒙Input_InterceptorOptions

harmony 鸿蒙Input_KeyEvent

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/8dQnAC