Comparison
Every number on this page was measured, not copied from a README. Measured on 15 November 2026 with the versions listed; the method is at the end so you can repeat it.
All exports of each library, bundled with its dependencies, minified and gzipped. Frameworks are left out for the React-only library.
| Library | Version | Minified | Gzipped |
|---|---|---|---|
| tinykeys | 4.0.1 | 2.4 kB | 1.24 kB |
| keymaster | 1.6.2 | 4.9 kB | 2.04 kB |
| shortcutter | 0.3 | 7.4 kB | 2.80 kB |
| @github/hotkey | 3.1.4 | 6.3 kB | 2.80 kB |
| mousetrap | 1.6.5 | 7.7 kB | 2.96 kB |
| shortcutter + @shortcutter/react | 0.3 | 3.03 kB | |
| shortcutter + sequences | 0.3 | 9.8 kB | 3.51 kB |
| react-hotkeys-hook (React only) | 5.4.0 | 10.2 kB | 3.48 kB |
| hotkeys-js | 4.1.2 | 10.7 kB | 4.03 kB |
| @tanstack/hotkeys | 0.29.0 | 59.7 kB | 16.5 kB |
None of them has runtime dependencies. shortcutter’s sequences live in a separate entry, so they cost nothing unless imported.
Game input: movement and sprint
Section titled “Game input: movement and sprint”A player holds A, adds Shift, adds W, releases A, releases W, presses D and releases Shift. After each of the 10 steps the game reads which directions are held and whether the player sprints. Events were realistic: key turns uppercase while Shift is held, keyCode is set for older libraries, and the last key auto-repeats.
| Library | How the game reads input | Steps right |
|---|---|---|
| shortcutter | isPressed() / subscribe() |
10 / 10 |
| hotkeys-js | isPressed() |
10 / 10 |
| keymaster | isPressed() |
10 / 10 |
| @tanstack/hotkeys | KeyStateTracker |
10 / 10 |
| react-hotkeys-hook | isHotkeyPressed() |
10 / 10 |
| tinykeys | a keydown and keyup binding per key | 2 / 10 |
| tinykeys | the same, plus Shift+… bindings for every key |
10 / 10 |
| mousetrap | a keydown and keyup binding per key | 2 / 10 |
| mousetrap | the same, plus shift+… bindings for every key |
10 / 10 |
| shortcutter | listen() per key (wrong tool, see below) |
1 / 10 |
listen() matches whole combinations, which is right for app shortcuts and wrong for movement: see the Games guide.
Stuck keys after alt-tab
Section titled “Stuck keys after alt-tab”W + Shift held, the window loses focus (the keyups happen elsewhere), the player comes back holding nothing and presses D. The right answer is “nothing held”, then “D”.
| Library | Steps right |
|---|---|
| shortcutter | 5 / 5 |
| hotkeys-js | 5 / 5 |
| @tanstack/hotkeys | 5 / 5 |
| react-hotkeys-hook | 5 / 5 |
| keymaster | 2 / 5: keeps running with W + sprint |
| tinykeys (with Shift bindings) | 2 / 5: state is kept by your own code, which never hears the keyups |
| mousetrap (with Shift bindings) | 2 / 5: same as tinykeys |
shortcutter also releases keys when the tab is hidden or the page is left, and trusts each event’s modifier flags, so a modifier pressed or released outside the page does not get stuck.
What each one is built around
Section titled “What each one is built around”From each library’s own README:
- tinykeys: the smallest. Physical-key matching (
event.code), a cross-platform modifier, sequences, keyup through an option. - keymaster: scopes and a pressed-key query, in a small, older package.
- @github/hotkey: declarative
data-hotkeyattributes that click or focus elements, sequences, scoping to a form field. - mousetrap: sequences and keyup bindings; widely used, last released as 1.6.5.
- react-hotkeys-hook: React only. Scopes, sequences, and a
descriptionoption with a list of registered hotkeys for help panels. - hotkeys-js: scopes, keyup, a catch-all
*listener and a pressed-keys query. - @tanstack/hotkeys: the most complete. A cross-platform
Modkey, keydown and keyup, sequences, key-state tracking, cheatsheet and recorder helpers, framework adapters, devtools and SSR support.
Where shortcutter fits
Section titled “Where shortcutter fits”shortcutter aims for the feature set of the larger libraries at the size of the small ones: contexts with several active at once, three phases including key repeat, wildcards, self-documenting shortcuts, a key-state API, optional sequences, adapters for React, Vue, Svelte and Solid, and safe server rendering, in under 3 kB gzipped for the core.
Pick something else when:
- you only need a handful of shortcuts and every byte counts: tinykeys;
- you want shortcuts declared in HTML attributes: @github/hotkey;
- you need a shortcut recorder UI, devtools or type-checked shortcut strings today: @tanstack/hotkeys.
Method
Section titled “Method”- Size: each library installed from npm with install scripts disabled; an entry file re-exporting everything was bundled with Vite (Rolldown) in library mode, minified, and gzipped at level 9. React and React DOM were external.
- Behaviour: each library ran in happy-dom with synthetic keyboard events dispatched on the document body; game state was read after each step through the library’s documented API.