Skip to content
Eskais UI

Foundations

Shortcuts

Keyboard shortcuts on UI SDK's shared shortcuts: useShortcut with scopes, sequences (g i) and mod, ShortcutScope for a region or an open panel, ShortcutHint drawn with Kbd. Plain keys never fire while typing or composing.

Example

Go to inbox

Focus the card, then press U, P or G then I.

Installation

npx shadcn@latest add @eskais/shortcuts
Brings alongkbd

Usage

Import
import {  addScopeLabel,  addShortcut,  formatSteps,  isTypingTarget,  listShortcuts,  setScopeActive,  stepsOf,} from "@/components/ui/shortcuts-registry"import {  ariaKeyshortcuts,  formatShortcut,  shortcuts,  useShortcutHint,  formatShortcutSteps,  listShortcuts,  ShortcutHint,  ShortcutScope,  useAriaKeyshortcuts,  useShortcut,} from "@/components/ui/shortcuts"import { ScopeContext, useShortcut } from "@/components/ui/use-shortcut"

API reference

ShortcutScope

PropTypeDefault
namerequiredThe scope's name. Shortcuts registered inside it run only while it is active.string–
labelHow `ShortcutsDialog` titles this scope's group.string–
active`"focus"` (default): active while focus is inside, like an editor or a list. `true`: while mounted, like an open side panel. `false`: never.boolean | "focus""focus"

Also takes <div> attributes and render.

ShortcutHint

PropTypeDefault
keysrequiredKeys like `"u"`, `"mod+k"` or `"g i"`.string–

Also takes <kbd> attributes and render except children.

Other exports

addScopeLabeladdShortcutformatStepsisTypingTargetlistShortcutssetScopeActivestepsOfariaKeyshortcutsformatShortcutshortcutsuseShortcutHintformatShortcutStepsuseAriaKeyshortcutsuseShortcutScopeContexttype ListedShortcuttype ShortcutLayertype ShortcutRegistrationtype ShortcutHintPropstype ShortcutScopePropstype UseShortcutOptionstype ScopeContextValue

Accessibility

  • Plain keys never fire while someone types in a field or contenteditable, nor during IME composition.
  • Hints are aria-hidden Kbd; the control carries aria-keyshortcuts instead.

Agent actions

Nothing new: shortcuts press the same parts agents already press by name.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.