1e41f4b71Sopenharmony_ci# TapGesture 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci**TapGesture** is used to trigger a tap gesture with one, two, or more taps. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## APIs 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciTapGesture(value?: { count?: number, fingers?: number }) 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**Parameters** 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 19e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 20e41f4b71Sopenharmony_ci| 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.| 21e41f4b71Sopenharmony_ci| 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. If the value is greater than 1, the tap gesture will fail to be recognized when the number of fingers pressing the screen within 300 ms of the first finger's being pressed is less than the required number, or when the number of fingers lifted from the screen within 300 ms of the first finger's being lifted is less than the required number.<br>2. When the number of fingers touching the screen exceeds the set value, the gesture can be recognized.| 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci## Events 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci| Name| Description| 27e41f4b71Sopenharmony_ci| -------- | -------- | 28e41f4b71Sopenharmony_ci| onAction(event: (event: [GestureEvent](ts-gesture-settings.md#gestureevent)) => 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.| 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci## Attributes 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci| Name| Type |Description | 33e41f4b71Sopenharmony_ci| ---- | ------ | ---------------------------------------- | 34e41f4b71Sopenharmony_ci| tag<sup>11+</sup> | string | Tag for the tap gesture. It is used to distinguish the gesture during custom gesture judgment.| 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci## Example 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci```ts 39e41f4b71Sopenharmony_ci// xxx.ets 40e41f4b71Sopenharmony_ci@Entry 41e41f4b71Sopenharmony_ci@Component 42e41f4b71Sopenharmony_cistruct TapGestureExample { 43e41f4b71Sopenharmony_ci @State value: string = '' 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci build() { 46e41f4b71Sopenharmony_ci Column() { 47e41f4b71Sopenharmony_ci // The gesture event is triggered by double-tapping. 48e41f4b71Sopenharmony_ci Text('Click twice').fontSize(28) 49e41f4b71Sopenharmony_ci .gesture( 50e41f4b71Sopenharmony_ci TapGesture({ count: 2 }) 51e41f4b71Sopenharmony_ci .onAction((event: GestureEvent) => { 52e41f4b71Sopenharmony_ci if (event) { 53e41f4b71Sopenharmony_ci this.value = JSON.stringify(event.fingerList[0]) 54e41f4b71Sopenharmony_ci } 55e41f4b71Sopenharmony_ci }) 56e41f4b71Sopenharmony_ci ) 57e41f4b71Sopenharmony_ci Text(this.value) 58e41f4b71Sopenharmony_ci } 59e41f4b71Sopenharmony_ci .height(200) 60e41f4b71Sopenharmony_ci .width(300) 61e41f4b71Sopenharmony_ci .padding(20) 62e41f4b71Sopenharmony_ci .border({ width: 3 }) 63e41f4b71Sopenharmony_ci .margin(30) 64e41f4b71Sopenharmony_ci } 65e41f4b71Sopenharmony_ci} 66e41f4b71Sopenharmony_ci``` 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci 69