• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.multimodalInput.touchEvent (Touch Event)
2
3The **touchEvent** module provides touchscreen events reported by a device. It is inherited from [InputEvent](./js-apis-inputevent.md).
4
5>  **NOTE**
6>
7> 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.
8
9## Modules to Import
10
11```js
12import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput.touchEvent';
13```
14
15## Action
16
17Enumerates touch event types.
18
19**System capability**: SystemCapability.MultimodalInput.Input.Core
20
21| Name    | Value  | Description  |
22| ------ | ------ | ---- |
23| CANCEL | 0 | Cancellation of touch.|
24| DOWN   | 1 | Pressing of touch.|
25| MOVE   | 2 | Moving of touch.|
26| UP     | 3 | Lifting of touch.|
27
28## ToolType
29
30Enumerates touch tool types.
31
32**System capability**: SystemCapability.MultimodalInput.Input.Core
33
34| Name      | Value  | Description  |
35| -------- | ------ | ---- |
36| FINGER   | 0 | Finger  |
37| PEN      | 1 | Stylus   |
38| RUBBER   | 2 | Eraser |
39| BRUSH    | 3 | Brush  |
40| PENCIL   | 4 | Pencil  |
41| AIRBRUSH | 5 | Air brush  |
42| MOUSE    | 6 | Mouse  |
43| LENS     | 7 | Lens  |
44
45## SourceType
46
47Enumerates touch source types.
48
49**System capability**: SystemCapability.MultimodalInput.Input.Core
50
51| Name          | Value | Description  |
52| ------------ | ------ | ---- |
53| TOUCH_SCREEN | 0 | Touchscreen |
54| PEN          | 1 | Stylus |
55| TOUCH_PAD    | 2 | Touchpad |
56
57## Touch
58
59Defines the touch point information.
60
61**System capability**: SystemCapability.MultimodalInput.Input.Core
62
63| Name         | Type  | Readable  | Writable  | Description                                 |
64| ----------- | ------ | ---- | ---- | ----------------------------------- |
65| id          | number | Yes   | No   | Touch event ID.                               |
66| pressedTime | number | Yes   | No   | Press timestamp, in μs.                            |
67| screenX     | number | Yes   | No   | X coordinate of the touch position on the screen.                       |
68| screenY     | number | Yes   | No   | Y coordinate of the touch position on the screen.                       |
69| windowX     | number | Yes   | No   | X coordinate of the touch position in the window.                       |
70| windowY     | number | Yes   | No   | Y coordinate of the touch position in the window.                       |
71| pressure    | number | Yes   | No   | Pressure value. The value range is [0.0, 1.0]. The value 0.0 indicates that the pressure is not supported.      |
72| width       | number | Yes   | No   | Width of the touch area.                          |
73| height      | number | Yes   | No   | Height of the touch area.                          |
74| tiltX       | number | Yes   | No   | Angle relative to the YZ plane. The value range is [-90, 90]. A positive value indicates a rightward tilt.|
75| tiltY       | number | Yes   | No   | Angle relative to the XZ plane. The value range is [-90, 90]. A positive value indicates a downward tilt.|
76| toolX       | number | Yes   | No   | X coordinate of the center point of the tool area.                          |
77| toolY       | number | Yes   | No   | Y coordinate of the center point of the tool area.                          |
78| toolWidth   | number | Yes   | No   | Width of the tool area.                             |
79| toolHeight  | number | Yes   | No   | Height of the tool area.                             |
80| rawX        | number | Yes   | No   | X coordinate of the input device.                          |
81| rawY        | number | Yes   | No   | Y coordinate of the input device.                          |
82| toolType    | [ToolType](#tooltype) | Yes   | No   | Tool type.                               |
83
84## TouchEvent
85
86Defines a touch event.
87
88**System capability**: SystemCapability.MultimodalInput.Input.Core
89
90| Name        | Type      | Readable  | Writable  | Description       |
91| ---------- | ---------- | ---- | ---- | --------- |
92| action     | [Action](#action)     | Yes   | No   | Touch event type.    |
93| touch      | [Touch](#touch)      | Yes   | No   | Current touch point.  |
94| touches    | [Touch](#touch)[]    | Yes   | No   | All touch points.    |
95| sourceType | [SourceType](#sourcetype) | Yes   | No   | Touch source type.|
96