بنقرة واحدة
use-shortcut
Add scoped, accessible keyboard shortcuts to React apps with @remcostoeten/use-shortcut.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Add scoped, accessible keyboard shortcuts to React apps with @remcostoeten/use-shortcut.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | use-shortcut |
| description | Add scoped, accessible keyboard shortcuts to React apps with @remcostoeten/use-shortcut. |
Add scoped, accessible keyboard shortcuts to React apps with @remcostoeten/use-shortcut. Prefer the narrow React entrypoint for app code:
import { useShortcut } from "@remcostoeten/use-shortcut/react"
useShortcutBinding() for one cleanup-safe shortcut binding in a component.useShortcut() for fluent one-off bindings.useShortcutMap() or registerShortcutMap() for config-driven command sets..bind(...) when combos already exist as strings from settings or config.ignoreInputs is true.aria-live text and non-color status cues..on(...) registrations inside useEffect() and return cleanup that calls unbind().useCallback() or shortcut maps with useMemo() when needed.ShortcutResults when enabling, disabling, triggering, or unbinding is needed.createShortcutGroup() or useShortcutGroup().Add a declarative shortcut:
useShortcutBinding("mod+k", openCommandPalette, {
description: "Open command palette",
preventDefault: true,
})
Use a sequence:
useShortcutBinding("g then d", goToDashboard, {
description: "Go to dashboard",
sequenceTimeout: 1000,
})
Use scopes:
const $ = useShortcut({ activeScopes: "navigation" })
useEffect(() => {
const shortcut = $.in("editor").mod.key("s").on(saveFile)
$.setScopes("editor")
return () => shortcut.unbind()
}, [$, saveFile])
Use structured debug metadata:
const $ = useShortcut({
debug: {
console: true,
includeCode: true,
includeLocation: true,
includeKeyCode: true,
},
})
const unsubscribe = $.onDebug((event) => {
showShortcutTelemetry(event.input.combo, event.attempts)
})
Use per-shortcut attempt feedback:
useEffect(() => {
const result = $.shift.key("e").then("e").on(runProbe)
const removeAttempt = result.onAttempt?.((matched, event, details) => {
updateAttemptStatus({ matched, key: event.key, status: details?.status })
})
return () => {
removeAttempt?.()
result.unbind()
}
}, [$, runProbe, updateAttemptStatus])
Read references/api.md when you need exact entrypoints, option names, result shapes, parser/formatter utilities, or testing guidance.
Use the package scripts from the workspace root:
bun run package:typecheck
bun run package:test
bun run package:build
For docs changes, use:
bun run docs:lint
bun run docs:test
bun run docs:build