Skip to content
aq-ui
Back to HooksHook

Use Key Press

Open-code aq-ui React hook for Use Key Press.

Installation

pnpm dlx aq-ui@alpha add use-key-press

API reference

Client module

Import the parts you need, then jump to an export for its contract.

View full source

Quick start

"use client"

import { useKeyPress } from "@/hooks/use-key-press"

KeyMatcher

typeSource L7

Type contract for KeyMatcher.

type KeyMatcher = string | string[] | ((event: KeyboardEvent) => boolean)

useKeyPress

functionSource L19

Open-code aq-ui React hook for Use Key Press.

function useKeyPress(matcher: KeyMatcher, target?: Target<EventTarget>, { enabled = true, preventDefault = false }: UseKeyPressOptions = {}): boolean
Returns
boolean

Parameters

NameTypeDefault
matcherKeyMatcher—
target?Target<EventTarget>—
options?UseKeyPressOptions{}

UseKeyPressOptions

interfaceSource L9

Type contract for UseKeyPressOptions.

interface UseKeyPressOptions

Members

NameTypeDefault
enabled?booleantrue
preventDefault?booleanfalse

Registry dependencies

hook-target

Files

  • hooks/use-key-press.ts

Source