useDuxtShortcuts()
The keys the theme listens to.
Signature
const { shortcuts, keys, hint, on } = useDuxtShortcuts();
on('help', () => open());
const { open, toggle } = useDuxtShortcutSheet();
Notes
The one place that knows which keys are bound, so the sheet on ? and the
handlers cannot disagree. shortcuts is the list left live by the site's
shortcuts.singleCharacter policy, keys() draws one for the reader's own
keyboard (⌘ or Ctrl), and on() binds an action with every guard a global
binding needs — never while the reader is typing, never inside a dialog or
menu, never once something nearer has handled the key, and, for the unmodified
keys, only while the page's own content holds focus.
hint() is keys() for a control rather than for the sheet: it takes an action,
returns the keys as one string — ⌘K, Ctrl+K, ] — and returns undefined
where the policy unbound that action, so a template writes v-if and draws no
empty key cap. It is what the search button and the adjacent-page links print.
useDuxtShortcutSheet() is the sheet's open state, shared rather than owned by
the sheet, because ? is not the only way in: the header's trigger opens the
same dialog, and on a site with shortcuts.singleCharacter: false it is the only
thing that can. See
Keyboard shortcuts.