Shortcut Confirm

Shortcut Confirm is a copy-paste React component that stops keyboard shortcut deleted items before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/shortcut-confirm
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsKeyboard shortcut deleted items

Was this component page useful?

How do I install Shortcut Confirm?

pnpm dlx shadcn@latest add @bollard/shortcut-confirm

The files land in your project. They're yours to edit.

How do I use Shortcut Confirm in React?

shortcut-confirm-usage.tsx
import { isApplePlatform, ShortcutConfirm } from "@/components/ui/shortcut-confirm"

<ShortcutConfirm
  shortcut="Mod+Backspace"
  enabled={count > 0}
  action={`delete ${count} ${count === 1 ? "item" : "items"}`}
  onConfirm={() => {
    setItems((current) => current.filter((item) => !selected.has(item)))
    setLog(`Deleted ${count} ${count === 1 ? "item" : "items"}.`)
  }}
/>

What input mistakes does Shortcut Confirm catch?

  • A first press, which only arms and explains
  • Key auto-repeat from holding the shortcut
  • An extra modifier (a slipped Shift)
  • Any other key pressed between the two presses
  • Shortcuts typed inside inputs, unless allowInInputs
  • IME composition keystrokes

What props does Shortcut Confirm accept?

ShortcutConfirm props
PropTypeDefault
shortcut* (required)

The destructive chord, e.g. "Mod+Backspace" or "Mod+Shift+D".

string—
onConfirm* (required)

Runs on the confirming second press.

() => void—
window

Ms the second press has to land in.

number2000
enabled

Listen only while this is true, e.g. when something is selected.

booleantrue
allowInInputs

Also listen while typing in inputs and contenteditable. Off by default.

booleanfalse
action* (required)

What the shortcut does, used in every message, e.g. "delete 3 items".

string—
idleText

Templates: `{keys}` and `{action}` are filled in.

string"{keys} twice to {action}"
armedText

Prompt after the first press. `{shortcut}` and `{action}` are filled in.

string"Press {keys} again to {action}"
doneText

Shown after the action is confirmed.

string"Done: {action}"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Shortcut Confirm accessible?

  • Armed and done prompts render in a polite live region
  • Shortcut shown as ⌘ on Apple platforms and Ctrl elsewhere
  • Icons are aria-hidden

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Guards the keyboard path only; menu or button paths need their own confirm
  • Letters also match by physical key, so a layout remap could still trigger it

What expensive mistakes does Shortcut Confirm stop?

Keyboard shortcut deleted items

Also known as

keyboard shortcut · hotkey · cmd+backspace · keybinding · power user · press again · shortcuts

What dependencies does Shortcut Confirm require?

Shortcut Confirm facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameShortcut Confirm
Registry identifier@bollard/shortcut-confirm
Install commandnpx shadcn@latest add @bollard/shortcut-confirm
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Shortcut Confirm

How does Shortcut Confirm protect destructive mutations?

Shortcut Confirm prevents keyboard shortcut deleted items. Enforces deliberate friction against A first press, which only arms and explains, Key auto-repeat from holding the shortcut, An extra modifier (a slipped Shift), Any other key pressed between the two presses, Shortcuts typed inside inputs, unless allowInInputs, IME composition keystrokes. Limitation: authorize shortcut-confirm mutations on the server.

How do I install shortcut-confirm with shadcn?

Run `npx shadcn@latest add @bollard/shortcut-confirm`. Sources added: registry/default/shortcut-confirm/shortcut-confirm.tsx. Package requirements: lucide-react.

What props customize Shortcut Confirm?

Shortcut Confirm accepts `shortcut`, `onConfirm`, `window`, `enabled`, `allowInInputs`. Configures keyboard shortcut, hotkey, cmd+backspace behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of shortcut-confirm?

Guards the keyboard path only; menu or button paths need their own confirm. Letters also match by physical key, so a layout remap could still trigger it Server requirement: backend verification for shortcut-confirm.

How does Shortcut Confirm meet accessibility guidelines?

Armed and done prompts render in a polite live region. Shortcut shown as ⌘ on Apple platforms and Ctrl elsewhere. Icons are aria-hidden. Minimizes errors: shortcut deleted by accident, cmd backspace deleted all.

Which components pair with Shortcut Confirm?