Skip to content
Nizivo UI

Hotkeys

The @nizivo/react/hotkeys entry.

Import

import { registerHotkey, toTinykeys, useHotkey, useHotkeys } from '@nizivo/react/hotkeys';

Exports

Hotkey type

import type { Hotkey } from '@nizivo/react/hotkeys'

A shortcut and what it does.

NameTypeDefaultDescription
allowInInputsbooleanfalse

Also while focus is in a text field.

descriptionrequiredstring–

What it does, for a list of shortcuts: "Open the command menu".

idrequiredstring–

Unique in the page; registering an id again replaces the first.

keysrequiredstring–

"mod+k", "shift+?", "mod+shift+d", as Kbd keys takes them.

runrequired(event: KeyboardEvent) => void–
HotkeyInfo type

import type { HotkeyInfo } from '@nizivo/react/hotkeys'

A registered shortcut as useHotkeys lists it.

NameTypeDefaultDescription
descriptionrequiredstring–
idrequiredstring–
keysrequiredstring–
registerHotkey function

import { registerHotkey } from '@nizivo/react/hotkeys'

Registers a shortcut; returns the function that removes it.

function registerHotkey(hotkey: Hotkey): () => void

toTinykeys function

import { toTinykeys } from '@nizivo/react/hotkeys'

"mod+shift+k" → tinykeys' "$mod+Shift+k".

function toTinykeys(keys: string): string

useHotkey hook

import { useHotkey } from '@nizivo/react/hotkeys'

Registers a shortcut while the component is mounted (and not hidden in an Activity). run may change on every render; the latest one runs.

function useHotkey(hotkey: Hotkey): void

useHotkeys hook

import { useHotkeys } from '@nizivo/react/hotkeys'

Every registered shortcut, in registration order; none on the server.

function useHotkeys(): readonly HotkeyInfo[]

On this page