# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://laterly.gitbook.io/hooks-vue3/uselongpress.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
