A declarative way to add keyboard shortcuts to your browser applications.
import { createListener } from "keyboardist";
const listener = createListener();
listener.subscribe("shift+down", () => {
console.log("Pressed Shift + down");
});
// bindings can live on stackable layers — a modal can own the
// keyboard and hand it back when it closes
const modal = listener.layer("modal", { escape: close }, { exclusive: true });
const pop = modal.push();Anyone can write one keydown listener. What accumulates after that —
canonical key names instead of modifier-flag chains, staying quiet while the
user types into inputs and contenteditables, preventing default only on real
matches, and above all layers (a modal or command palette taking over the
keyboard and handing it back cleanly, even when overlapping) — is the code
every app ends up writing badly under deadline. Keyboardist is that code,
extracted, tested, ~3 kB gzipped with zero dependencies. The longer
version is in the
package README.
This is the Keyboardist monorepo:
| Package | Description |
|---|---|
packages/keyboardist |
The keyboardist npm package — core plus React hooks/components at the keyboardist/react subpath. Docs live in its README |
apps/website |
The demo website |
Requires Node 24 and pnpm:
pnpm install
pnpm dev # run the demo website at http://localhost:5100
pnpm check # lint + typecheck + test + buildSee CONTRIBUTING.md for the full workflow.
Versioning and publishing are automated with
Changesets; the changelog lives in
packages/keyboardist/CHANGELOG.md once
the first automated release lands.
The pre-monorepo 2.x state of this repository is preserved on the
v2 branch and the
archive/v2-final tag.
MIT © Armando Sosa
