Skip to content
aq-ui
Back to HooksHook

Use Hotkeys

Open-code aq-ui React hook for Use Hotkeys.

Installation

pnpm dlx aq-ui@alpha add use-hotkeys

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 { useHotkeys } from "@/hooks/use-hotkeys"

useHotkeys

functionSource L69

Open-code aq-ui React hook for Use Hotkeys.

function useHotkeys(hotkeys: string | string[], callback: (event: KeyboardEvent, hotkey: string) => void, { target, enabled = true, preventDefault = true, stopPropagation = false, allowInInputs = false, exactModifiers = true, }: UseHotkeysOptions = {}): void
Returns
void

Parameters

NameTypeDefault
hotkeysstring | string[]—
callback(event: KeyboardEvent, hotkey: string) => void—
options?UseHotkeysOptions{}

UseHotkeysOptions

interfaceSource L8

Type contract for UseHotkeysOptions.

interface UseHotkeysOptions

Members

NameTypeDefault
target?Target<EventTarget>—
enabled?booleantrue
preventDefault?booleantrue
stopPropagation?booleanfalse
allowInInputs?booleanfalse
exactModifiers?booleantrue

Registry dependencies

hook-target, use-stable-callback

Files

  • hooks/use-hotkeys.ts

Source