> For the complete documentation index, see [llms.txt](https://laterly.gitbook.io/hooks-vue3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://laterly.gitbook.io/hooks-vue3/uselongpress.md).

# useLongPress

#### 基础用法

```html
<template>
  <div>longPressed{{ longPressed ? "true" : "false" }}</div>
  <div>Click count {{ clickCount }}</div>
  <button ref="buttonRef">Click or Long Press Me</button>
  <button
    @click="
      () => {
        longPressed = false;
      }
    "
  >
    Rest
  </button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useLongPress } from "hooks-vue3";
const longPressed = ref<boolean>(false);
const buttonRef = ref(null);
const clickCount = ref(0);
useLongPress(
  () => {
    longPressed.value = true;
  },
  buttonRef,
  {
    delay: 1000,
    onClick() {
      clickCount.value++;
    },
  }
);
</script>
```

```html
```

### API

```typescript
useLongPress(() => void,target,{delay: 1000});
```

### 参数

```typescript
type Target<T> = T | (() => T) | Ref<T>;

interface UseLongPressOptions {
  delay?: number;
  onClick?: (event: PointerEvent) => void;
}

function useLongPress<T extends Element>(
  handler: (evt: PointerEvent) => void,
  target: Target<T | null>,
  options: UseLongPressOptions = {},
): void
```

```typescript
```

```typescript
```
