# ccampbell/mousetrap

Simple library for handling keyboard shortcuts in Javascript

Repository: https://github.com/ccampbell/mousetrap
Canonical: https://ross.abutalabs.com/products/mousetrap
Homepage: https://craig.is/killing/mice
Language: JavaScript
License: Apache-2.0
License Family: permissive
Topics: mousetrap, javascript, keyboard-shortcuts, keyboard
Last push: 2023-03-15T18:11:42+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 5172, "days_push": 1267, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 11777, forks 954 (observed 2026-08-28T04:10:49.758716+00:00)

## What it is
Mousetrap is a tiny (~2kb gzipped), dependency-free JavaScript library for binding keyboard shortcuts in the browser. It supports single keys, modifier combinations, and Gmail-style key sequences across keypress, keydown, and keyup events.

## Use cases
- add keyboard shortcuts to a web app
- bind ctrl+k style hotkeys in javascript
- implement gmail-like key sequences
- capture keyboard combinations in the browser
- handle special keys like ? and esc in javascript
- support international keyboard layouts for shortcuts

## When to choose
- you need a tiny, framework-agnostic shortcut library with no dependencies
- you want key sequences and combinations with international keyboard support
- you need broad legacy browser compatibility including IE6+

## When to avoid
- you need shortcuts in non-browser environments like Electron menus or OS-level global hotkeys
- you want a library with active ongoing development and modern maintenance
- you need mouse or pointer event handling alongside keyboard events

## Facets
- artifact type: library
- maturity: maintenance
- function: ui-components, developer-tools
- domain: web-development, frontend, developer-tools
- platform: browser
- tags: keyboard-shortcuts, hotkeys, keybindings, event-handling, zero-dependency, javascript, nodejs

## Member repositories
- ccampbell/mousetrap (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:10:49.758716+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:15:20.227550+00:00, confidence not recorded.
  - readme: https://github.com/ccampbell/mousetrap (fetched 2026-08-28T04:10:49.758716+00:00, sha 415f4cf7503a)
  - homepage: https://craig.is/killing/mice (fetched 2026-08-29T08:13:44.369510+00:00, sha 557d7fefff50)
  - registry_npm: https://registry.npmjs.org/mousetrap (fetched 2026-08-29T08:13:44.379187+00:00, sha 2674f0756cf6)
- Data as of 2026-08-30T08:39:29.467469+00:00.
