combokeys
Version:
Handles keyboard shortcuts in the browser
24 lines (22 loc) • 670 B
JavaScript
/* eslint-env node, browser */
/**
* binds an event to Combokeys
*
* can be a single key, a combination of keys separated with +,
* an array of keys, or a sequence of keys separated by spaces
*
* be sure to list the modifier keys first to make sure that the
* correct key ends up getting bound (the last key in the pattern)
*
* @param {string|Array} keys
* @param {Function} callback
* @param {string=} action - "keypress", "keydown", or "keyup"
* @returns void
*/
module.exports = function (keys, callback, action) {
var self = this
keys = keys instanceof Array ? keys : [keys]
self.bindMultiple(keys, callback, action)
return self
}