Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hotkeys-js

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotkeys-js - npm Package Compare versions

Comparing version 3.6.4 to 3.6.5

doc/website.375873b7.js

34

dist/hotkeys.common.js
/*!
* hotkeys-js v3.6.4
* hotkeys-js v3.6.5
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.

@@ -141,3 +141,3 @@ *

var isBindElement = false; // 是否绑定节点
var elementHasBindEvent = []; // 已绑定事件的节点记录
// 返回键码

@@ -357,2 +357,7 @@

}
} // 判断 element 是否已经绑定事件
function isElementBind(element) {
return elementHasBindEvent.indexOf(element) > -1;
}

@@ -379,7 +384,7 @@

if (option.element) element = option.element; // eslint-disable-line
if (option.element) element = option.element; // eslint-disable-line
if (option.keyup) keyup = option.keyup; // eslint-disable-line
if (option.keyup) keyup = option.keyup; // eslint-disable-line
if (option.keydown) keydown = option.keydown; // eslint-disable-line
if (option.keydown) keydown = option.keydown; // eslint-disable-line
}

@@ -414,16 +419,9 @@

if (typeof element !== 'undefined' && !isBindElement) {
isBindElement = true;
if (keydown) {
addEvent(element, 'keydown', function (e) {
dispatch(e);
});
}
if (typeof element !== 'undefined' && !isElementBind(element)) {
elementHasBindEvent.push(element);
addEvent(element, 'keydown', function (e) {
dispatch(e);
});
addEvent(element, 'keyup', function (e) {
if (keyup) {
dispatch(e);
}
dispatch(e);
clearModifier(e);

@@ -430,0 +428,0 @@ });

@@ -1,2 +0,2 @@

/*! hotkeys-js v3.6.4 | MIT (c) 2019 kenny wong <wowohoo@qq.com> | http://jaywcjlove.github.io/hotkeys */
"use strict";var isff="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function addEvent(e,o,t){e.addEventListener?e.addEventListener(o,t,!1):e.attachEvent&&e.attachEvent("on".concat(o),function(){t(window.event)})}function getMods(e,o){for(var t=o.slice(0,o.length-1),n=0;n<t.length;n++)t[n]=e[t[n].toLowerCase()];return t}function getKeys(e){e||(e="");for(var o=(e=e.replace(/\s/g,"")).split(","),t=o.lastIndexOf("");0<=t;)o[t-1]+=",",o.splice(t,1),t=o.lastIndexOf("");return o}function compareArray(e,o){for(var t=e.length<o.length?o:e,n=e.length<o.length?e:o,r=!0,s=0;s<t.length;s++)~n.indexOf(t[s])||(r=!1);return r}for(var _keyMap={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,"\u21ea":20,",":188,".":190,"/":191,"`":192,"-":isff?173:189,"=":isff?61:187,";":isff?59:186,"'":222,"[":219,"]":221,"\\":220},_modifier={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":isff?224:91,cmd:isff?224:91,command:isff?224:91},_downKeys=[],modifierMap={16:"shiftKey",18:"altKey",17:"ctrlKey"},_mods={16:!1,18:!1,17:!1},_handlers={},k=1;k<20;k++)_keyMap["f".concat(k)]=111+k;var _scope="all",isBindElement=_mods[isff?224:91]=!(modifierMap[isff?224:91]="metaKey"),code=function(e){return _keyMap[e.toLowerCase()]||_modifier[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function setScope(e){_scope=e||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function filter(e){var o=e.target||e.srcElement,t=o.tagName;return!("INPUT"===t||"SELECT"===t||"TEXTAREA"===t||o.isContentEditable)}function isPressed(e){return"string"==typeof e&&(e=code(e)),!!~_downKeys.indexOf(e)}function deleteScope(e,o){var t,n;for(var r in e||(e=getScope()),_handlers)if(Object.prototype.hasOwnProperty.call(_handlers,r))for(t=_handlers[r],n=0;n<t.length;)t[n].scope===e?t.splice(n,1):n++;getScope()===e&&setScope(o||"all")}function clearModifier(e){var o=e.keyCode||e.which||e.charCode,t=_downKeys.indexOf(o);if(t<0||_downKeys.splice(t,1),e.key&&"meta"==e.key.toLowerCase()&&_downKeys.splice(0,_downKeys.length),93!==o&&224!==o||(o=91),o in _mods)for(var n in _mods[o]=!1,_modifier)_modifier[n]===o&&(hotkeys[n]=!1)}function unbind(e,o,t){var n,r,s=getKeys(e),d=[];"function"==typeof o&&(t=o,o="all");for(var i=0;i<s.length;i++){if(1<(n=s[i].split("+")).length&&(d=getMods(_modifier,n)),e="*"===(e=n[n.length-1])?"*":code(e),o||(o=getScope()),!_handlers[e])return;for(var a=0;a<_handlers[e].length;a++){r=_handlers[e][a],t&&r.method!==t||r.scope!==o||!compareArray(r.mods,d)||(_handlers[e][a]={})}}}function eventHandler(e,o,t){var n;if(o.scope===t||"all"===o.scope){for(var r in n=0<o.mods.length,_mods)Object.prototype.hasOwnProperty.call(_mods,r)&&(!_mods[r]&&-1<o.mods.indexOf(+r)||_mods[r]&&!~o.mods.indexOf(+r))&&(n=!1);(0!==o.mods.length||_mods[16]||_mods[18]||_mods[17]||_mods[91])&&!n&&"*"!==o.shortcut||!1===o.method(e,o)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function dispatch(e){var o=_handlers["*"],t=e.keyCode||e.which||e.charCode;if(~_downKeys.indexOf(t)||_downKeys.push(t),93!==t&&224!==t||(t=91),t in _mods){for(var n in _mods[t]=!0,_modifier)_modifier[n]===t&&(hotkeys[n]=!0);if(!o)return}for(var r in _mods)Object.prototype.hasOwnProperty.call(_mods,r)&&(_mods[r]=e[modifierMap[r]]);if(hotkeys.filter.call(this,e)){var s=getScope();if(o)for(var d=0;d<o.length;d++)o[d].scope===s&&("keydown"===e.type&&!o[d].keyup||"keyup"===e.type&&o[d].keyup)&&eventHandler(e,o[d],s);if(t in _handlers)for(var i=0;i<_handlers[t].length;i++)if(("keydown"===e.type&&_handlers[t][i].keydown||"keyup"===e.type&&_handlers[t][i].keyup)&&_handlers[t][i].key){for(var a=_handlers[t][i].key.split("+"),l=[],c=0;c<a.length;c++)l.push(code(a[c]));(l=l.sort()).join("")===_downKeys.sort().join("")&&eventHandler(e,_handlers[t][i],s)}}}function hotkeys(e,o,t){var n=getKeys(e),r=[],s="all",d=document,i=0,a=!1,l=!0;for(void 0===t&&"function"==typeof o&&(t=o),"[object Object]"===Object.prototype.toString.call(o)&&(o.scope&&(s=o.scope),o.element&&(d=o.element),o.keyup&&(a=o.keyup),o.keydown&&(l=o.keydown)),"string"==typeof o&&(s=o);i<n.length;i++)r=[],1<(e=n[i].split("+")).length&&(r=getMods(_modifier,e)),(e="*"===(e=e[e.length-1])?"*":code(e))in _handlers||(_handlers[e]=[]),_handlers[e].push({keyup:a,keydown:l,scope:s,mods:r,shortcut:n[i],method:t,key:n[i]});void 0===d||isBindElement||(isBindElement=!0,l&&addEvent(d,"keydown",function(e){dispatch(e)}),addEvent(d,"keyup",function(e){a&&dispatch(e),clearModifier(e)}))}var _api={setScope:setScope,getScope:getScope,deleteScope:deleteScope,getPressedKeyCodes:getPressedKeyCodes,isPressed:isPressed,filter:filter,unbind:unbind};for(var a in _api)Object.prototype.hasOwnProperty.call(_api,a)&&(hotkeys[a]=_api[a]);if("undefined"!=typeof window){var _hotkeys=window.hotkeys;hotkeys.noConflict=function(e){return e&&window.hotkeys===hotkeys&&(window.hotkeys=_hotkeys),hotkeys},window.hotkeys=hotkeys}module.exports=hotkeys;
/*! hotkeys-js v3.6.5 | MIT (c) 2019 kenny wong <wowohoo@qq.com> | http://jaywcjlove.github.io/hotkeys */
"use strict";var isff="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function addEvent(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent&&e.attachEvent("on".concat(t),function(){o(window.event)})}function getMods(e,t){for(var o=t.slice(0,t.length-1),n=0;n<o.length;n++)o[n]=e[o[n].toLowerCase()];return o}function getKeys(e){e||(e="");for(var t=(e=e.replace(/\s/g,"")).split(","),o=t.lastIndexOf("");0<=o;)t[o-1]+=",",t.splice(o,1),o=t.lastIndexOf("");return t}function compareArray(e,t){for(var o=e.length<t.length?t:e,n=e.length<t.length?e:t,s=!0,r=0;r<o.length;r++)~n.indexOf(o[r])||(s=!1);return s}for(var _keyMap={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,"\u21ea":20,",":188,".":190,"/":191,"`":192,"-":isff?173:189,"=":isff?61:187,";":isff?59:186,"'":222,"[":219,"]":221,"\\":220},_modifier={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":isff?224:91,cmd:isff?224:91,command:isff?224:91},_downKeys=[],modifierMap={16:"shiftKey",18:"altKey",17:"ctrlKey"},_mods={16:!1,18:!1,17:!1},_handlers={},k=1;k<20;k++)_keyMap["f".concat(k)]=111+k;_mods[isff?224:91]=!(modifierMap[isff?224:91]="metaKey");var _scope="all",elementHasBindEvent=[],code=function(e){return _keyMap[e.toLowerCase()]||_modifier[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function setScope(e){_scope=e||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function filter(e){var t=e.target||e.srcElement,o=t.tagName;return!("INPUT"===o||"SELECT"===o||"TEXTAREA"===o||t.isContentEditable)}function isPressed(e){return"string"==typeof e&&(e=code(e)),!!~_downKeys.indexOf(e)}function deleteScope(e,t){var o,n;for(var s in e||(e=getScope()),_handlers)if(Object.prototype.hasOwnProperty.call(_handlers,s))for(o=_handlers[s],n=0;n<o.length;)o[n].scope===e?o.splice(n,1):n++;getScope()===e&&setScope(t||"all")}function clearModifier(e){var t=e.keyCode||e.which||e.charCode,o=_downKeys.indexOf(t);if(o<0||_downKeys.splice(o,1),e.key&&"meta"==e.key.toLowerCase()&&_downKeys.splice(0,_downKeys.length),93!==t&&224!==t||(t=91),t in _mods)for(var n in _mods[t]=!1,_modifier)_modifier[n]===t&&(hotkeys[n]=!1)}function unbind(e,t,o){var n,s,r=getKeys(e),d=[];"function"==typeof t&&(o=t,t="all");for(var i=0;i<r.length;i++){if(1<(n=r[i].split("+")).length&&(d=getMods(_modifier,n)),e="*"===(e=n[n.length-1])?"*":code(e),t||(t=getScope()),!_handlers[e])return;for(var a=0;a<_handlers[e].length;a++){s=_handlers[e][a],o&&s.method!==o||s.scope!==t||!compareArray(s.mods,d)||(_handlers[e][a]={})}}}function eventHandler(e,t,o){var n;if(t.scope===o||"all"===t.scope){for(var s in n=0<t.mods.length,_mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(!_mods[s]&&-1<t.mods.indexOf(+s)||_mods[s]&&!~t.mods.indexOf(+s))&&(n=!1);(0!==t.mods.length||_mods[16]||_mods[18]||_mods[17]||_mods[91])&&!n&&"*"!==t.shortcut||!1===t.method(e,t)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function dispatch(e){var t=_handlers["*"],o=e.keyCode||e.which||e.charCode;if(~_downKeys.indexOf(o)||_downKeys.push(o),93!==o&&224!==o||(o=91),o in _mods){for(var n in _mods[o]=!0,_modifier)_modifier[n]===o&&(hotkeys[n]=!0);if(!t)return}for(var s in _mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(_mods[s]=e[modifierMap[s]]);if(hotkeys.filter.call(this,e)){var r=getScope();if(t)for(var d=0;d<t.length;d++)t[d].scope===r&&("keydown"===e.type&&!t[d].keyup||"keyup"===e.type&&t[d].keyup)&&eventHandler(e,t[d],r);if(o in _handlers)for(var i=0;i<_handlers[o].length;i++)if(("keydown"===e.type&&_handlers[o][i].keydown||"keyup"===e.type&&_handlers[o][i].keyup)&&_handlers[o][i].key){for(var a=_handlers[o][i].key.split("+"),l=[],c=0;c<a.length;c++)l.push(code(a[c]));(l=l.sort()).join("")===_downKeys.sort().join("")&&eventHandler(e,_handlers[o][i],r)}}}function isElementBind(e){return-1<elementHasBindEvent.indexOf(e)}function hotkeys(e,t,o){var n=getKeys(e),s=[],r="all",d=document,i=0,a=!1,l=!0;for(void 0===o&&"function"==typeof t&&(o=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(r=t.scope),t.element&&(d=t.element),t.keyup&&(a=t.keyup),t.keydown&&(l=t.keydown)),"string"==typeof t&&(r=t);i<n.length;i++)s=[],1<(e=n[i].split("+")).length&&(s=getMods(_modifier,e)),(e="*"===(e=e[e.length-1])?"*":code(e))in _handlers||(_handlers[e]=[]),_handlers[e].push({keyup:a,keydown:l,scope:r,mods:s,shortcut:n[i],method:o,key:n[i]});void 0===d||isElementBind(d)||(elementHasBindEvent.push(d),addEvent(d,"keydown",function(e){dispatch(e)}),addEvent(d,"keyup",function(e){dispatch(e),clearModifier(e)}))}var _api={setScope:setScope,getScope:getScope,deleteScope:deleteScope,getPressedKeyCodes:getPressedKeyCodes,isPressed:isPressed,filter:filter,unbind:unbind};for(var a in _api)Object.prototype.hasOwnProperty.call(_api,a)&&(hotkeys[a]=_api[a]);if("undefined"!=typeof window){var _hotkeys=window.hotkeys;hotkeys.noConflict=function(e){return e&&window.hotkeys===hotkeys&&(window.hotkeys=_hotkeys),hotkeys},window.hotkeys=hotkeys}module.exports=hotkeys;
/*!
* hotkeys-js v3.6.4
* hotkeys-js v3.6.5
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.

@@ -139,3 +139,3 @@ *

var isBindElement = false; // 是否绑定节点
var elementHasBindEvent = []; // 已绑定事件的节点记录
// 返回键码

@@ -355,2 +355,7 @@

}
} // 判断 element 是否已经绑定事件
function isElementBind(element) {
return elementHasBindEvent.indexOf(element) > -1;
}

@@ -377,7 +382,7 @@

if (option.element) element = option.element; // eslint-disable-line
if (option.element) element = option.element; // eslint-disable-line
if (option.keyup) keyup = option.keyup; // eslint-disable-line
if (option.keyup) keyup = option.keyup; // eslint-disable-line
if (option.keydown) keydown = option.keydown; // eslint-disable-line
if (option.keydown) keydown = option.keydown; // eslint-disable-line
}

@@ -412,16 +417,9 @@

if (typeof element !== 'undefined' && !isBindElement) {
isBindElement = true;
if (keydown) {
addEvent(element, 'keydown', function (e) {
dispatch(e);
});
}
if (typeof element !== 'undefined' && !isElementBind(element)) {
elementHasBindEvent.push(element);
addEvent(element, 'keydown', function (e) {
dispatch(e);
});
addEvent(element, 'keyup', function (e) {
if (keyup) {
dispatch(e);
}
dispatch(e);
clearModifier(e);

@@ -428,0 +426,0 @@ });

/*!
* hotkeys-js v3.6.4
* hotkeys-js v3.6.5
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.

@@ -145,3 +145,3 @@ *

var isBindElement = false; // 是否绑定节点
var elementHasBindEvent = []; // 已绑定事件的节点记录
// 返回键码

@@ -361,2 +361,7 @@

}
} // 判断 element 是否已经绑定事件
function isElementBind(element) {
return elementHasBindEvent.indexOf(element) > -1;
}

@@ -383,7 +388,7 @@

if (option.element) element = option.element; // eslint-disable-line
if (option.element) element = option.element; // eslint-disable-line
if (option.keyup) keyup = option.keyup; // eslint-disable-line
if (option.keyup) keyup = option.keyup; // eslint-disable-line
if (option.keydown) keydown = option.keydown; // eslint-disable-line
if (option.keydown) keydown = option.keydown; // eslint-disable-line
}

@@ -418,16 +423,9 @@

if (typeof element !== 'undefined' && !isBindElement) {
isBindElement = true;
if (keydown) {
addEvent(element, 'keydown', function (e) {
dispatch(e);
});
}
if (typeof element !== 'undefined' && !isElementBind(element)) {
elementHasBindEvent.push(element);
addEvent(element, 'keydown', function (e) {
dispatch(e);
});
addEvent(element, 'keyup', function (e) {
if (keyup) {
dispatch(e);
}
dispatch(e);
clearModifier(e);

@@ -434,0 +432,0 @@ });

@@ -1,2 +0,2 @@

/*! hotkeys-js v3.6.4 | MIT (c) 2019 kenny wong <wowohoo@qq.com> | http://jaywcjlove.github.io/hotkeys */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).hotkeys=t()}(this,function(){"use strict";var e="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function s(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on".concat(t),function(){n(window.event)})}function p(e,t){for(var n=t.slice(0,t.length-1),o=0;o<n.length;o++)n[o]=e[n[o].toLowerCase()];return n}function u(e){e||(e="");for(var t=(e=e.replace(/\s/g,"")).split(","),n=t.lastIndexOf("");0<=n;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function l(e,t){for(var n=e.length<t.length?t:e,o=e.length<t.length?e:t,r=!0,i=0;i<n.length;i++)~o.indexOf(n[i])||(r=!1);return r}for(var t={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,"\u21ea":20,",":188,".":190,"/":191,"`":192,"-":e?173:189,"=":e?61:187,";":e?59:186,"'":222,"[":219,"]":221,"\\":220},d={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":e?224:91,cmd:e?224:91,command:e?224:91},y=[],h={16:"shiftKey",18:"altKey",17:"ctrlKey"},v={16:!1,18:!1,17:!1},g={},n=1;n<20;n++)t["f".concat(n)]=111+n;var o="all",w=v[e?224:91]=!(h[e?224:91]="metaKey"),k=function(e){return t[e.toLowerCase()]||d[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function i(e){o=e||"all"}function m(){return o||"all"}function O(e,t,n){var o;if(t.scope===n||"all"===t.scope){for(var r in o=0<t.mods.length,v)Object.prototype.hasOwnProperty.call(v,r)&&(!v[r]&&-1<t.mods.indexOf(+r)||v[r]&&!~t.mods.indexOf(+r))&&(o=!1);(0!==t.mods.length||v[16]||v[18]||v[17]||v[91])&&!o&&"*"!==t.shortcut||!1===t.method(e,t)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function b(e){var t=g["*"],n=e.keyCode||e.which||e.charCode;if(~y.indexOf(n)||y.push(n),93!==n&&224!==n||(n=91),n in v){for(var o in v[n]=!0,d)d[o]===n&&(C[o]=!0);if(!t)return}for(var r in v)Object.prototype.hasOwnProperty.call(v,r)&&(v[r]=e[h[r]]);if(C.filter.call(this,e)){var i=m();if(t)for(var a=0;a<t.length;a++)t[a].scope===i&&("keydown"===e.type&&!t[a].keyup||"keyup"===e.type&&t[a].keyup)&&O(e,t[a],i);if(n in g)for(var c=0;c<g[n].length;c++)if(("keydown"===e.type&&g[n][c].keydown||"keyup"===e.type&&g[n][c].keyup)&&g[n][c].key){for(var f=g[n][c].key.split("+"),l=[],s=0;s<f.length;s++)l.push(k(f[s]));(l=l.sort()).join("")===y.sort().join("")&&O(e,g[n][c],i)}}}function C(e,t,n){var o=u(e),r=[],i="all",a=document,c=0,f=!1,l=!0;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(i=t.scope),t.element&&(a=t.element),t.keyup&&(f=t.keyup),t.keydown&&(l=t.keydown)),"string"==typeof t&&(i=t);c<o.length;c++)r=[],1<(e=o[c].split("+")).length&&(r=p(d,e)),(e="*"===(e=e[e.length-1])?"*":k(e))in g||(g[e]=[]),g[e].push({keyup:f,keydown:l,scope:i,mods:r,shortcut:o[c],method:n,key:o[c]});void 0===a||w||(w=!0,l&&s(a,"keydown",function(e){b(e)}),s(a,"keyup",function(e){f&&b(e),function(e){var t=e.keyCode||e.which||e.charCode,n=y.indexOf(t);if(n<0||y.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&y.splice(0,y.length),93!==t&&224!==t||(t=91),t in v)for(var o in v[t]=!1,d)d[o]===t&&(C[o]=!1)}(e)}))}var r={setScope:i,getScope:m,deleteScope:function(e,t){var n,o;for(var r in e||(e=m()),g)if(Object.prototype.hasOwnProperty.call(g,r))for(n=g[r],o=0;o<n.length;)n[o].scope===e?n.splice(o,1):o++;m()===e&&i(t||"all")},getPressedKeyCodes:function(){return y.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=k(e)),!!~y.indexOf(e)},filter:function(e){var t=e.target||e.srcElement,n=t.tagName;return!("INPUT"===n||"SELECT"===n||"TEXTAREA"===n||t.isContentEditable)},unbind:function(e,t,n){var o,r,i=u(e),a=[];"function"==typeof t&&(n=t,t="all");for(var c=0;c<i.length;c++){if(1<(o=i[c].split("+")).length&&(a=p(d,o)),e="*"===(e=o[o.length-1])?"*":k(e),t||(t=m()),!g[e])return;for(var f=0;f<g[e].length;f++)r=g[e][f],n&&r.method!==n||r.scope!==t||!l(r.mods,a)||(g[e][f]={})}}};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(C[a]=r[a]);if("undefined"!=typeof window){var c=window.hotkeys;C.noConflict=function(e){return e&&window.hotkeys===C&&(window.hotkeys=c),C},window.hotkeys=C}return C});
/*! hotkeys-js v3.6.5 | MIT (c) 2019 kenny wong <wowohoo@qq.com> | http://jaywcjlove.github.io/hotkeys */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).hotkeys=t()}(this,function(){"use strict";var e="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function s(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on".concat(t),function(){n(window.event)})}function p(e,t){for(var n=t.slice(0,t.length-1),o=0;o<n.length;o++)n[o]=e[n[o].toLowerCase()];return n}function u(e){e||(e="");for(var t=(e=e.replace(/\s/g,"")).split(","),n=t.lastIndexOf("");0<=n;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function l(e,t){for(var n=e.length<t.length?t:e,o=e.length<t.length?e:t,r=!0,i=0;i<n.length;i++)~o.indexOf(n[i])||(r=!1);return r}for(var t={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,"\u21ea":20,",":188,".":190,"/":191,"`":192,"-":e?173:189,"=":e?61:187,";":e?59:186,"'":222,"[":219,"]":221,"\\":220},d={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":e?224:91,cmd:e?224:91,command:e?224:91},y=[],h={16:"shiftKey",18:"altKey",17:"ctrlKey"},v={16:!1,18:!1,17:!1},g={},n=1;n<20;n++)t["f".concat(n)]=111+n;v[e?224:91]=!(h[e?224:91]="metaKey");var o="all",w=[],k=function(e){return t[e.toLowerCase()]||d[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function i(e){o=e||"all"}function m(){return o||"all"}function O(e,t,n){var o;if(t.scope===n||"all"===t.scope){for(var r in o=0<t.mods.length,v)Object.prototype.hasOwnProperty.call(v,r)&&(!v[r]&&-1<t.mods.indexOf(+r)||v[r]&&!~t.mods.indexOf(+r))&&(o=!1);(0!==t.mods.length||v[16]||v[18]||v[17]||v[91])&&!o&&"*"!==t.shortcut||!1===t.method(e,t)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function b(e){var t=g["*"],n=e.keyCode||e.which||e.charCode;if(~y.indexOf(n)||y.push(n),93!==n&&224!==n||(n=91),n in v){for(var o in v[n]=!0,d)d[o]===n&&(C[o]=!0);if(!t)return}for(var r in v)Object.prototype.hasOwnProperty.call(v,r)&&(v[r]=e[h[r]]);if(C.filter.call(this,e)){var i=m();if(t)for(var a=0;a<t.length;a++)t[a].scope===i&&("keydown"===e.type&&!t[a].keyup||"keyup"===e.type&&t[a].keyup)&&O(e,t[a],i);if(n in g)for(var c=0;c<g[n].length;c++)if(("keydown"===e.type&&g[n][c].keydown||"keyup"===e.type&&g[n][c].keyup)&&g[n][c].key){for(var f=g[n][c].key.split("+"),l=[],s=0;s<f.length;s++)l.push(k(f[s]));(l=l.sort()).join("")===y.sort().join("")&&O(e,g[n][c],i)}}}function C(e,t,n){var o=u(e),r=[],i="all",a=document,c=0,f=!1,l=!0;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(i=t.scope),t.element&&(a=t.element),t.keyup&&(f=t.keyup),t.keydown&&(l=t.keydown)),"string"==typeof t&&(i=t);c<o.length;c++)r=[],1<(e=o[c].split("+")).length&&(r=p(d,e)),(e="*"===(e=e[e.length-1])?"*":k(e))in g||(g[e]=[]),g[e].push({keyup:f,keydown:l,scope:i,mods:r,shortcut:o[c],method:n,key:o[c]});void 0===a||function(e){return-1<w.indexOf(e)}(a)||(w.push(a),s(a,"keydown",function(e){b(e)}),s(a,"keyup",function(e){b(e),function(e){var t=e.keyCode||e.which||e.charCode,n=y.indexOf(t);if(n<0||y.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&y.splice(0,y.length),93!==t&&224!==t||(t=91),t in v)for(var o in v[t]=!1,d)d[o]===t&&(C[o]=!1)}(e)}))}var r={setScope:i,getScope:m,deleteScope:function(e,t){var n,o;for(var r in e||(e=m()),g)if(Object.prototype.hasOwnProperty.call(g,r))for(n=g[r],o=0;o<n.length;)n[o].scope===e?n.splice(o,1):o++;m()===e&&i(t||"all")},getPressedKeyCodes:function(){return y.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=k(e)),!!~y.indexOf(e)},filter:function(e){var t=e.target||e.srcElement,n=t.tagName;return!("INPUT"===n||"SELECT"===n||"TEXTAREA"===n||t.isContentEditable)},unbind:function(e,t,n){var o,r,i=u(e),a=[];"function"==typeof t&&(n=t,t="all");for(var c=0;c<i.length;c++){if(1<(o=i[c].split("+")).length&&(a=p(d,o)),e="*"===(e=o[o.length-1])?"*":k(e),t||(t=m()),!g[e])return;for(var f=0;f<g[e].length;f++)r=g[e][f],n&&r.method!==n||r.scope!==t||!l(r.mods,a)||(g[e][f]={})}}};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(C[a]=r[a]);if("undefined"!=typeof window){var c=window.hotkeys;C.noConflict=function(e){return e&&window.hotkeys===C&&(window.hotkeys=c),C},window.hotkeys=C}return C});
{
"name": "hotkeys-js",
"description": "A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.",
"version": "3.6.4",
"version": "3.6.5",
"main": "index.js",

@@ -6,0 +6,0 @@ "module": "dist/hotkeys.esm.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc