Skip to content

Repository files navigation

🎹 Keyboardist

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();

Why

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

Development

Requires Node 24 and pnpm:

pnpm install
pnpm dev     # run the demo website at http://localhost:5100
pnpm check   # lint + typecheck + test + build

See CONTRIBUTING.md for the full workflow.

Releases

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.

License

MIT © Armando Sosa

About

An easy way to add keyboard shortcuts to your javascript applications.

Resources

Code of conduct

Contributing

Security policy

Stars

37 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages