combokeys
Version:
Handles keyboard shortcuts in the browser
31 lines (24 loc) • 435 B
JavaScript
/* eslint-env node, browser */
/**
* takes a key event and figures out what the modifiers are
*
* @param {Event} e
* @returns {Array}
*/
module.exports = function (e) {
var modifiers = []
if (e.shiftKey) {
modifiers.push('shift')
}
if (e.altKey) {
modifiers.push('alt')
}
if (e.ctrlKey) {
modifiers.push('ctrl')
}
if (e.metaKey) {
modifiers.push('meta')
}
return modifiers
}