Mousetrap : Keyboard shortcuts in Javascript

Mousetrap : Keyboard shortcuts in Javascript

A simple library for handling keyboard shortcuts in Javascript.Mousetrap is a standalone library with no external dependencies. It weighs in at around 1.4kb minified and gzipped.Any keyboard event that has been bound can be triggered by passing in the string you used when you bound it originally.Note that this is not actually triggering a key event in the browser. It is simply firing the event you bound to that key within mousetrap

The feature was inspired by Gmail. Any keys separated by a space will be considered a sequence. If you type each key in order the final one in the sequence will trigger the callback. If you type a key not in the sequence or wait too long the sequence will reset.Any key events that would normally fire for keys within a sequence will not fire if they are pressed within the context of that sequence.

Leave a Reply