Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/usePointerLock.md
1---2category: Sensors3---45# usePointerLock67Reactive [pointer lock](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API).89## Basic Usage1011```ts12import { usePointerLock } from '@vueuse/core'1314const {15isSupported,16lock,17unlock,18element,19triggerElement20} = usePointerLock()21```2223## Component Usage2425```vue26<template>27<UsePointerLock v-slot="{ lock }">28<canvas />29<button @click="lock">30Lock Pointer on Canvas31</button>32</UsePointerLock>33</template>34```3536## Type Declarations3738```ts39export interface UsePointerLockOptions extends ConfigurableDocument {}40export interface UsePointerLockReturn extends Supportable {41element: ShallowRef<MaybeElement>42triggerElement: ShallowRef<MaybeElement>43lock: (e: MaybeElementRef | Event) => Promise<MaybeElement>44unlock: () => Promise<boolean>45}46/**47* Reactive pointer lock.48*49* @see https://vueuse.org/usePointerLock50* @param target51* @param options52*53* @__NO_SIDE_EFFECTS__54*/55export declare function usePointerLock(56target?: MaybeElementRef,57options?: UsePointerLockOptions,58): UsePointerLockReturn59```60