MCPcopy Index your code
hub / github.com/ccampbell/mousetrap

github.com/ccampbell/mousetrap @1.6.5 sqlite

repository ↗ · DeepWiki ↗ · release 1.6.5 ↗
95 symbols 204 edges 15 files 26 documented · 27%
README

Mousetrap

CDNJS

Mousetrap is a simple library for handling keyboard shortcuts in Javascript.

It is licensed under the Apache 2.0 license.

It is around 2kb minified and gzipped and 4.5kb minified, has no external dependencies, and has been tested in the following browsers:

  • Internet Explorer 6+
  • Safari
  • Firefox
  • Chrome

It has support for keypress, keydown, and keyup events on specific keys, keyboard combinations, or key sequences.

Getting started

  1. Include mousetrap on your page before the closing </body> tag

    html <script src="https://github.com/ccampbell/mousetrap/raw/1.6.5/path/to/mousetrap.min.js"></script>

    or install mousetrap from npm and require it

    js var Mousetrap = require('mousetrap');

  2. Add some keyboard events to listen for

    ```html ```

Why Mousetrap?

There are a number of other similar libraries out there so what makes this one different?

  • There are no external dependencies, no framework is required
  • You are not limited to keydown events (You can specify keypress, keydown, or keyup or let Mousetrap choose for you).
  • You can bind key events directly to special keys such as ? or * without having to specify shift+/ or shift+8 which are not consistent across all keyboards
  • It works with international keyboard layouts
  • You can bind Gmail like key sequences in addition to regular keys and key combinations
  • You can programatically trigger key events with the trigger() method
  • It works with the numeric keypad on your keyboard
  • The code is well documented/commented

Tests

Unit tests are run with mocha.

Running in browser

View it online to check your browser compatibility. You may also download the repo and open tests/mousetrap.html in your browser.

Running with Node.js

  1. Install development dependencies

    sh cd /path/to/repo npm install

  2. Run tests

    sh npm test

Documentation

Full documentation can be found at https://craig.is/killing/mice

Core symbols most depended-on inside this repo

Mousetrap
called by 4
mousetrap.js
_addEvent
called by 3
mousetrap.js
_isModifier
called by 3
mousetrap.js
_fireCallback
called by 3
mousetrap.js
_characterFromEvent
called by 2
mousetrap.js
_getKeyInfo
called by 2
mousetrap.js
_getMatches
called by 2
mousetrap.js
_bindSingle
called by 2
mousetrap.js

Shape

Function 95

Languages

TypeScript100%

Modules by API surface

tests/libs/jquery-1.7.2.min.js42 symbols
mousetrap.js22 symbols
mousetrap.min.js15 symbols
plugins/record/mousetrap-record.js6 symbols
plugins/record/mousetrap-record.min.js5 symbols
plugins/record/tests/jelly.js3 symbols
tests/test.mousetrap.js1 symbols
tests/libs/key-event.js1 symbols

Dependencies from manifests, versioned

chai4.2.0 · 1×
grunt1.0.3 · 1×
grunt-complexity1.1.0 · 1×
jsdom13.1.0 · 1×
jsdom-global3.0.2 · 1×
mocha5.2.0 · 1×
sinon7.2.2 · 1×

For agents

$ claude mcp add mousetrap \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact