1# TapGesture
2
3**TapGesture** is used to trigger a tap gesture with one, two, or more taps.
4
5>  **NOTE**
6>
7>  This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8
9
10## APIs
11
12TapGesture(value?: TapGestureParameters)
13
14**Atomic service API**: This API can be used in atomic services since API version 12.
15
16**System capability**: SystemCapability.ArkUI.ArkUI.Full
17
18**Parameters**
19
20| Name| Type| Mandatory| Description|
21| -------- | -------- | -------- | -------- |
22| value | [TapGestureParameters](#tapgestureparameters12) | No| Parameters related to the tap gesture.|
23
24## TapGestureParameters<sup>12+</sup>
25
26**Atomic service API**: This API can be used in atomic services since API version 12.
27
28**System capability**: SystemCapability.ArkUI.ArkUI.Full
29
30| Name| Type| Mandatory| Description|
31| -------- | -------- | -------- | -------- |
32| count | number | No| Number of consecutive taps. If the value is less than 1 or is not set, the default value is used.<br>Default value: **1**<br>**NOTE**<br>1. If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms.<br>2. If the distance between the last tapped position and the current tapped position exceeds 60 vp, gesture recognition fails. In multi-finger scenarios, the tapped position is the average position of all fingers involved in the gesture response.|
33| fingers | number | No| Number of fingers required to trigger a tap. The value ranges from 1 to 10. If the value is less than 1 or is not set, the default value is used.<br>Default value: **1**<br>**NOTE**<br>1. For a multi-finger gesture, recognition fails if the required number of fingers is not pressed within 300 ms after the first finger; when fingers are lifted, if the remaining number of fingers is below the threshold after lifting, all fingers must be lifted within 300 ms for the gesture to be successfully recognized.<br>2. When the number of fingers touching the screen exceeds the set value, the gesture can be recognized.|
34| distanceThreshold | number | No| Movement threshold for the tap gesture. If the value is less than or equal to 0 or is not set, the default value is used.<br>Default value: 2^31-1<br>**NOTE**<br>If the finger movement exceeds the preset movement threshold, the tap gesture recognition fails. If the default threshold is used during initialization and the finger moves beyond the component's touch target, the tap gesture recognition fails.|
35
36## Events
37
38| Name| Description|
39| -------- | -------- |
40| onAction(event: (event: [GestureEvent](ts-gesture-settings.md#gestureevent)) =&gt; void) | Callback invoked when a tap gesture is recognized.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
41
42## Attributes
43
44| Name| Type   |Description                                       |
45| ----  | ------  | ---------------------------------------- |
46| tag<sup>11+</sup>   | string  | Tag for the tap gesture. It is used to distinguish the gesture during custom gesture judgment.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
47| allowedTypes<sup>14+</sup> | Array\<[SourceTool](ts-gesture-settings.md#sourcetool9)> | Allowed event input types for the tap gesture.<br>**Atomic service API**: This API can be used in atomic services since API version 14.|
48
49## Example
50
51This example demonstrates the recognition of a double-tap gesture using **TapGesture**.
52
53```ts
54// xxx.ets
55@Entry
56@Component
57struct TapGestureExample {
58  @State value: string = ''
59
60  build() {
61    Column() {
62      // The gesture event is triggered by double-tapping.
63      Text('Click twice').fontSize(28)
64        .gesture(
65        TapGesture({ count: 2 })
66          .onAction((event: GestureEvent) => {
67            if (event) {
68              this.value = JSON.stringify(event.fingerList[0])
69            }
70          })
71        )
72      Text(this.value)
73    }
74    .height(200)
75    .width(300)
76    .padding(20)
77    .border({ width: 3 })
78    .margin(30)
79  }
80}
81```
82
83![en-us_image_0000001174422900](figures/en-us_image_0000001174422900.gif)
84