Mousetrap is a dependency-free JavaScript library for binding keyboard shortcuts.
Mousetrap, weighing only 1.4kb compressed, makes shortcut binding impressively effective.
We aren’t that fond of snippets, but here’s some code that shows how succinct and simple the library is:
Mousetrap.bind('ctrl+s', function(e) {
_saveDraft();
});
Even if you don’t have the need for keyboard shortcuts now, do bookmark Mousetrap so it’s there when the need arises.















