finds.dev← search

// the find

jaywcjlove/hotkeys-js

★ 7,124 · TypeScript · MIT · updated Sep 2026

➷ A robust Javascript library for capturing keyboard input. It has no dependencies.

hotkeys-js is a dependency-free browser library for binding keyboard shortcuts with a single `hotkeys('ctrl+s', handler)` call, with support for combos, scopes, keyup handlers and per-element binding. It suits front-end developers who want shortcuts in a plain page or a framework without adopting a larger input-handling stack. It has around 7k stars, was pushed to within the last month, and the source is small enough to read in one sitting.

Zero dependencies and about 3.8kB gzipped, which fits a page that already has a bundle budget. The dist folder ships IIFE, UMD and ES module builds, so it works with or without a bundler. The API covers the cases people actually hit: scopes via setScope and deleteScope for modal-level shortcuts, per-binding element targeting, keyup mode, a custom splitKey, and a single option that unbinds the previous handler instead of stacking duplicates. It ships TypeScript declarations and a test suite, and the filter hook is a clean way to override the default suppression inside inputs.

Matching is built on the legacy numeric keyCode values, so letter shortcuts can behave differently on non-US layouts such as AZERTY. Test on the layouts your users run before relying on it. All state lives in one module-level registry, so two pieces of code binding shortcuts on the same page can collide, and a bare hotkeys.unbind() clears every binding, not just yours. It supports simultaneous chords only, with no key sequences, so Vim-style 'g then h' bindings need another library. The README has rot: its own example compares event.target to the string 'input', which never matches, and the browser support list still claims Internet Explorer 6+. Read the source rather than trusting the examples.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →