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 GI
shortcuts-demo.tsxCopy code
Installation
Copy code
Brings alongkbd
Usage
ImportCopy code
API reference
ShortcutScope
| Prop | Type | Default |
|---|---|---|
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
| Prop | Type | Default |
|---|---|---|
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 ScopeContextValueAccessibility
- 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.