hotkey
one check for a bare key a page answers, so a letter never lands in a field by surprise.
bunx --bun shadcn@latest add @mk/hotkeyexample
isPageKey(event, "n") takes a keydown and the key you want. call it from a listener on the document. search-palette opens on / through it and quick-add’s nav field opens on n. press n on this page, then type one in the field.
- n on the page
- 0
both copies on this page count together.
- n on the page
- 0
both copies on this page count together.
when it says no
it says no in text, a textarea, a select or anything editable, and inside a dialog, a menu or a list, because a modal holds the page and a menu jumps to the item a letter starts. it also says no to a held key, a key with a modifier, a key mid-composition and a key something else already took. caps lock changes nothing.