Combokeys

combokeys

Handles keyboard shortcuts in the browser.

combokeys is a fork of ccampbell/mousetrap with two main changes:

  • Refactored as CommonJS
  • Doesn't automatically listen on the document. Instead, it is now a constructor and the element on which to listen must be provided on instantiation.

Install it: npm install --save combokeys

Sample usage:

1
2
3
4
5
6
7
var Combokeys = require("combokeys");
var Mousetrap = new Combokeys(document.documentElement);
// Or, instantiate it for one or more specific elements:
var firstCombokeys = new Combokeys(document.getElementById("first"));

firstCombokeys.bind('4', function() { console.log('4'); });
firstCombokeys.bind("?", function() { console.log('show shortcuts!'); });

GIF FTW!

combokeys

Thanks to Shahar Or for porting mousetrap to combokeys.

Suggest a module

Comments