Socket
Socket
Sign inDemoInstall

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.7.6 to 3.8.0

14

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

@@ -72,3 +72,3 @@ *

enter: 13,
"return": 13,
return: 13,
esc: 27,

@@ -82,3 +82,3 @@ escape: 27,

del: 46,
"delete": 46,
delete: 46,
ins: 45,

@@ -366,2 +366,10 @@ insert: 45,

_downKeys.splice(_downKeys.indexOf(keyNum), 1);
} else if (keyName === 'metaKey' && event[keyName] && _downKeys.length === 3) {
/**
* Fix if Command is pressed:
* ===============================
*/
if (!(event.ctrlKey || event.shiftKey || event.altKey)) {
_downKeys = _downKeys.slice(_downKeys.indexOf(keyNum));
}
}

@@ -368,0 +376,0 @@ });

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

/*! hotkeys-js v3.7.6 | MIT (c) 2020 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){"string"!=typeof 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":91,cmd:91,command:91},modifierMap={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},_mods={16:!1,18:!1,17:!1,91:!1},_handlers={},k=1;k<20;k++)_keyMap["f".concat(k)]=111+k;var _downKeys=[],_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,n=!0;return!t.isContentEditable&&("INPUT"!==o&&"TEXTAREA"!==o||t.readOnly)||(n=!1),n}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){if(e){if(Array.isArray(e))e.forEach(function(e){e.key&&eachUnbind(e)});else if("object"==typeof e)e.key&&eachUnbind(e);else if("string"==typeof e){for(var t=arguments.length,o=Array(1<t?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];var s=o[0],r=o[1];"function"==typeof s&&(r=s,s=""),eachUnbind({key:e,scope:s,method:r,splitKey:"+"})}}else Object.keys(_handlers).forEach(function(e){return delete _handlers[e]})}var eachUnbind=function(e){var i=e.scope,d=e.method,t=e.splitKey,a=void 0===t?"+":t;getKeys(e.key).forEach(function(e){var t=e.split(a),o=t.length,n=t[o-1],s="*"===n?"*":code(n);if(_handlers[s]){i=i||getScope();var r=1<o?getMods(_modifier,t):[];_handlers[s]=_handlers[s].map(function(e){return d&&e.method!==d||e.scope!==i||!compareArray(e.mods,r)?e:{}})}})};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]&&~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(o){var e=_handlers["*"],t=o.keyCode||o.which||o.charCode;if(hotkeys.filter.call(this,o)){if(93!==t&&224!==t||(t=91),~_downKeys.indexOf(t)||229===t||_downKeys.push(t),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var t=modifierMap[e];o[e]&&!~_downKeys.indexOf(t)?_downKeys.push(t):!o[e]&&~_downKeys.indexOf(t)&&_downKeys.splice(_downKeys.indexOf(t),1)}),t in _mods){for(var n in _mods[t]=!0,_modifier)_modifier[n]===t&&(hotkeys[n]=!0);if(!e)return}for(var s in _mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(_mods[s]=o[modifierMap[s]]);o.getModifierState&&(!o.altKey||o.ctrlKey)&&o.getModifierState("AltGraph")&&(~_downKeys.indexOf(17)||_downKeys.push(17),~_downKeys.indexOf(18)||_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);var r=getScope();if(e)for(var i=0;i<e.length;i++)e[i].scope===r&&("keydown"===o.type&&e[i].keydown||"keyup"===o.type&&e[i].keyup)&&eventHandler(o,e[i],r);if(t in _handlers)for(var d=0;d<_handlers[t].length;d++)if(("keydown"===o.type&&_handlers[t][d].keydown||"keyup"===o.type&&_handlers[t][d].keyup)&&_handlers[t][d].key){for(var a=_handlers[t][d],c=a.key.split(a.splitKey),l=[],f=0;f<c.length;f++)l.push(code(c[f]));l.sort().join("")===_downKeys.sort().join("")&&eventHandler(o,a,r)}}}function isElementBind(e){return!!~elementHasBindEvent.indexOf(e)}function hotkeys(e,t,o){_downKeys=[];var n=getKeys(e),s=[],r="all",i=document,d=0,a=!1,c=!0,l="+";for(void 0===o&&"function"==typeof t&&(o=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(r=t.scope),t.element&&(i=t.element),t.keyup&&(a=t.keyup),void 0!==t.keydown&&(c=t.keydown),"string"==typeof t.splitKey&&(l=t.splitKey)),"string"==typeof t&&(r=t);d<n.length;d++)s=[],1<(e=n[d].split(l)).length&&(s=getMods(_modifier,e)),(e="*"===(e=e[e.length-1])?"*":code(e))in _handlers||(_handlers[e]=[]),_handlers[e].push({keyup:a,keydown:c,scope:r,mods:s,shortcut:n[d],method:o,key:n[d],splitKey:l});void 0!==i&&!isElementBind(i)&&window&&(elementHasBindEvent.push(i),addEvent(i,"keydown",function(e){dispatch(e)}),addEvent(window,"focus",function(){_downKeys=[]}),addEvent(i,"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.8.0 | MIT (c) 2020 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){"string"!=typeof 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":91,cmd:91,command:91},modifierMap={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},_mods={16:!1,18:!1,17:!1,91:!1},_handlers={},k=1;k<20;k++)_keyMap["f".concat(k)]=111+k;var _downKeys=[],_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,n=!0;return!t.isContentEditable&&("INPUT"!==o&&"TEXTAREA"!==o||t.readOnly)||(n=!1),n}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){if(e){if(Array.isArray(e))e.forEach(function(e){e.key&&eachUnbind(e)});else if("object"==typeof e)e.key&&eachUnbind(e);else if("string"==typeof e){for(var t=arguments.length,o=Array(1<t?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];var s=o[0],r=o[1];"function"==typeof s&&(r=s,s=""),eachUnbind({key:e,scope:s,method:r,splitKey:"+"})}}else Object.keys(_handlers).forEach(function(e){return delete _handlers[e]})}var eachUnbind=function(e){var d=e.scope,i=e.method,t=e.splitKey,a=void 0===t?"+":t;getKeys(e.key).forEach(function(e){var t=e.split(a),o=t.length,n=t[o-1],s="*"===n?"*":code(n);if(_handlers[s]){d=d||getScope();var r=1<o?getMods(_modifier,t):[];_handlers[s]=_handlers[s].map(function(e){return i&&e.method!==i||e.scope!==d||!compareArray(e.mods,r)?e:{}})}})};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]&&~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(o){var e=_handlers["*"],t=o.keyCode||o.which||o.charCode;if(hotkeys.filter.call(this,o)){if(93!==t&&224!==t||(t=91),~_downKeys.indexOf(t)||229===t||_downKeys.push(t),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var t=modifierMap[e];o[e]&&!~_downKeys.indexOf(t)?_downKeys.push(t):!o[e]&&~_downKeys.indexOf(t)?_downKeys.splice(_downKeys.indexOf(t),1):"metaKey"===e&&o[e]&&3===_downKeys.length&&(o.ctrlKey||o.shiftKey||o.altKey||(_downKeys=_downKeys.slice(_downKeys.indexOf(t))))}),t in _mods){for(var n in _mods[t]=!0,_modifier)_modifier[n]===t&&(hotkeys[n]=!0);if(!e)return}for(var s in _mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(_mods[s]=o[modifierMap[s]]);o.getModifierState&&(!o.altKey||o.ctrlKey)&&o.getModifierState("AltGraph")&&(~_downKeys.indexOf(17)||_downKeys.push(17),~_downKeys.indexOf(18)||_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);var r=getScope();if(e)for(var d=0;d<e.length;d++)e[d].scope===r&&("keydown"===o.type&&e[d].keydown||"keyup"===o.type&&e[d].keyup)&&eventHandler(o,e[d],r);if(t in _handlers)for(var i=0;i<_handlers[t].length;i++)if(("keydown"===o.type&&_handlers[t][i].keydown||"keyup"===o.type&&_handlers[t][i].keyup)&&_handlers[t][i].key){for(var a=_handlers[t][i],c=a.key.split(a.splitKey),l=[],f=0;f<c.length;f++)l.push(code(c[f]));l.sort().join("")===_downKeys.sort().join("")&&eventHandler(o,a,r)}}}function isElementBind(e){return!!~elementHasBindEvent.indexOf(e)}function hotkeys(e,t,o){_downKeys=[];var n=getKeys(e),s=[],r="all",d=document,i=0,a=!1,c=!0,l="+";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),void 0!==t.keydown&&(c=t.keydown),"string"==typeof t.splitKey&&(l=t.splitKey)),"string"==typeof t&&(r=t);i<n.length;i++)s=[],1<(e=n[i].split(l)).length&&(s=getMods(_modifier,e)),(e="*"===(e=e[e.length-1])?"*":code(e))in _handlers||(_handlers[e]=[]),_handlers[e].push({keyup:a,keydown:c,scope:r,mods:s,shortcut:n[i],method:o,key:n[i],splitKey:l});void 0!==d&&!isElementBind(d)&&window&&(elementHasBindEvent.push(d),addEvent(d,"keydown",function(e){dispatch(e)}),addEvent(window,"focus",function(){_downKeys=[]}),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.7.6
* hotkeys-js v3.8.0
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.

@@ -70,3 +70,3 @@ *

enter: 13,
"return": 13,
return: 13,
esc: 27,

@@ -80,3 +80,3 @@ escape: 27,

del: 46,
"delete": 46,
delete: 46,
ins: 45,

@@ -364,2 +364,10 @@ insert: 45,

_downKeys.splice(_downKeys.indexOf(keyNum), 1);
} else if (keyName === 'metaKey' && event[keyName] && _downKeys.length === 3) {
/**
* Fix if Command is pressed:
* ===============================
*/
if (!(event.ctrlKey || event.shiftKey || event.altKey)) {
_downKeys = _downKeys.slice(_downKeys.indexOf(keyNum));
}
}

@@ -366,0 +374,0 @@ });

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

@@ -76,3 +76,3 @@ *

enter: 13,
"return": 13,
return: 13,
esc: 27,

@@ -86,3 +86,3 @@ escape: 27,

del: 46,
"delete": 46,
delete: 46,
ins: 45,

@@ -370,2 +370,10 @@ insert: 45,

_downKeys.splice(_downKeys.indexOf(keyNum), 1);
} else if (keyName === 'metaKey' && event[keyName] && _downKeys.length === 3) {
/**
* Fix if Command is pressed:
* ===============================
*/
if (!(event.ctrlKey || event.shiftKey || event.altKey)) {
_downKeys = _downKeys.slice(_downKeys.indexOf(keyNum));
}
}

@@ -372,0 +380,0 @@ });

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

/*! hotkeys-js v3.7.6 | MIT (c) 2020 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 p(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on".concat(t),function(){n(window.event)})}function d(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 y(e){"string"!=typeof 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}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},u={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,command:91},h={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},v={16:!1,18:!1,17:!1,91:!1},g={},n=1;n<20;n++)t["f".concat(n)]=111+n;var w=[],o="all",k=[],m=function(e){return t[e.toLowerCase()]||u[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function i(e){o=e||"all"}function O(){return o||"all"}function f(e){var f=e.scope,a=e.method,t=e.splitKey,c=void 0===t?"+":t;y(e.key).forEach(function(e){var t=e.split(c),n=t.length,o=t[n-1],r="*"===o?"*":m(o);if(g[r]){f=f||O();var i=1<n?d(u,t):[];g[r]=g[r].map(function(e){return a&&e.method!==a||e.scope!==f||!function(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}(e.mods,i)?e:{}})}})}function K(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]&&~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(n){var e=g["*"],t=n.keyCode||n.which||n.charCode;if(x.filter.call(this,n)){if(93!==t&&224!==t||(t=91),~w.indexOf(t)||229===t||w.push(t),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var t=h[e];n[e]&&!~w.indexOf(t)?w.push(t):!n[e]&&~w.indexOf(t)&&w.splice(w.indexOf(t),1)}),t in v){for(var o in v[t]=!0,u)u[o]===t&&(x[o]=!0);if(!e)return}for(var r in v)Object.prototype.hasOwnProperty.call(v,r)&&(v[r]=n[h[r]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~w.indexOf(17)||w.push(17),~w.indexOf(18)||w.push(18),v[17]=!0,v[18]=!0);var i=O();if(e)for(var f=0;f<e.length;f++)e[f].scope===i&&("keydown"===n.type&&e[f].keydown||"keyup"===n.type&&e[f].keyup)&&K(n,e[f],i);if(t in g)for(var a=0;a<g[t].length;a++)if(("keydown"===n.type&&g[t][a].keydown||"keyup"===n.type&&g[t][a].keyup)&&g[t][a].key){for(var c=g[t][a],s=c.key.split(c.splitKey),l=[],p=0;p<s.length;p++)l.push(m(s[p]));l.sort().join("")===w.sort().join("")&&K(n,c,i)}}}function x(e,t,n){w=[];var o=y(e),r=[],i="all",f=document,a=0,c=!1,s=!0,l="+";for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(i=t.scope),t.element&&(f=t.element),t.keyup&&(c=t.keyup),void 0!==t.keydown&&(s=t.keydown),"string"==typeof t.splitKey&&(l=t.splitKey)),"string"==typeof t&&(i=t);a<o.length;a++)r=[],1<(e=o[a].split(l)).length&&(r=d(u,e)),(e="*"===(e=e[e.length-1])?"*":m(e))in g||(g[e]=[]),g[e].push({keyup:c,keydown:s,scope:i,mods:r,shortcut:o[a],method:n,key:o[a],splitKey:l});void 0!==f&&!~k.indexOf(f)&&window&&(k.push(f),p(f,"keydown",function(e){b(e)}),p(window,"focus",function(){w=[]}),p(f,"keyup",function(e){b(e),function(e){var t=e.keyCode||e.which||e.charCode,n=w.indexOf(t);if(n<0||w.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&w.splice(0,w.length),93!==t&&224!==t||(t=91),t in v)for(var o in v[t]=!1,u)u[o]===t&&(x[o]=!1)}(e)}))}var r={setScope:i,getScope:O,deleteScope:function(e,t){var n,o;for(var r in e=e||O(),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++;O()===e&&i(t||"all")},getPressedKeyCodes:function(){return w.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=m(e)),!!~w.indexOf(e)},filter:function(e){var t=e.target||e.srcElement,n=t.tagName,o=!0;return!t.isContentEditable&&("INPUT"!==n&&"TEXTAREA"!==n||t.readOnly)||(o=!1),o},unbind:function(e){if(e){if(Array.isArray(e))e.forEach(function(e){e.key&&f(e)});else if("object"==typeof e)e.key&&f(e);else if("string"==typeof e){for(var t=arguments.length,n=Array(1<t?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];var r=n[0],i=n[1];"function"==typeof r&&(i=r,r=""),f({key:e,scope:r,method:i,splitKey:"+"})}}else Object.keys(g).forEach(function(e){return delete g[e]})}};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(x[a]=r[a]);if("undefined"!=typeof window){var c=window.hotkeys;x.noConflict=function(e){return e&&window.hotkeys===x&&(window.hotkeys=c),x},window.hotkeys=x}return x});
/*! hotkeys-js v3.8.0 | MIT (c) 2020 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 p(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on".concat(t),function(){n(window.event)})}function y(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 d(e){"string"!=typeof 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}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},u={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,command:91},h={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},v={16:!1,18:!1,17:!1,91:!1},g={},n=1;n<20;n++)t["f".concat(n)]=111+n;var w=[],o="all",k=[],m=function(e){return t[e.toLowerCase()]||u[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function i(e){o=e||"all"}function O(){return o||"all"}function f(e){var f=e.scope,a=e.method,t=e.splitKey,c=void 0===t?"+":t;d(e.key).forEach(function(e){var t=e.split(c),n=t.length,o=t[n-1],r="*"===o?"*":m(o);if(g[r]){f=f||O();var i=1<n?y(u,t):[];g[r]=g[r].map(function(e){return a&&e.method!==a||e.scope!==f||!function(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}(e.mods,i)?e:{}})}})}function K(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]&&~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 x(n){var e=g["*"],t=n.keyCode||n.which||n.charCode;if(b.filter.call(this,n)){if(93!==t&&224!==t||(t=91),~w.indexOf(t)||229===t||w.push(t),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var t=h[e];n[e]&&!~w.indexOf(t)?w.push(t):!n[e]&&~w.indexOf(t)?w.splice(w.indexOf(t),1):"metaKey"===e&&n[e]&&3===w.length&&(n.ctrlKey||n.shiftKey||n.altKey||(w=w.slice(w.indexOf(t))))}),t in v){for(var o in v[t]=!0,u)u[o]===t&&(b[o]=!0);if(!e)return}for(var r in v)Object.prototype.hasOwnProperty.call(v,r)&&(v[r]=n[h[r]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~w.indexOf(17)||w.push(17),~w.indexOf(18)||w.push(18),v[17]=!0,v[18]=!0);var i=O();if(e)for(var f=0;f<e.length;f++)e[f].scope===i&&("keydown"===n.type&&e[f].keydown||"keyup"===n.type&&e[f].keyup)&&K(n,e[f],i);if(t in g)for(var a=0;a<g[t].length;a++)if(("keydown"===n.type&&g[t][a].keydown||"keyup"===n.type&&g[t][a].keyup)&&g[t][a].key){for(var c=g[t][a],l=c.key.split(c.splitKey),s=[],p=0;p<l.length;p++)s.push(m(l[p]));s.sort().join("")===w.sort().join("")&&K(n,c,i)}}}function b(e,t,n){w=[];var o=d(e),r=[],i="all",f=document,a=0,c=!1,l=!0,s="+";for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(i=t.scope),t.element&&(f=t.element),t.keyup&&(c=t.keyup),void 0!==t.keydown&&(l=t.keydown),"string"==typeof t.splitKey&&(s=t.splitKey)),"string"==typeof t&&(i=t);a<o.length;a++)r=[],1<(e=o[a].split(s)).length&&(r=y(u,e)),(e="*"===(e=e[e.length-1])?"*":m(e))in g||(g[e]=[]),g[e].push({keyup:c,keydown:l,scope:i,mods:r,shortcut:o[a],method:n,key:o[a],splitKey:s});void 0!==f&&!~k.indexOf(f)&&window&&(k.push(f),p(f,"keydown",function(e){x(e)}),p(window,"focus",function(){w=[]}),p(f,"keyup",function(e){x(e),function(e){var t=e.keyCode||e.which||e.charCode,n=w.indexOf(t);if(n<0||w.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&w.splice(0,w.length),93!==t&&224!==t||(t=91),t in v)for(var o in v[t]=!1,u)u[o]===t&&(b[o]=!1)}(e)}))}var r={setScope:i,getScope:O,deleteScope:function(e,t){var n,o;for(var r in e=e||O(),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++;O()===e&&i(t||"all")},getPressedKeyCodes:function(){return w.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=m(e)),!!~w.indexOf(e)},filter:function(e){var t=e.target||e.srcElement,n=t.tagName,o=!0;return!t.isContentEditable&&("INPUT"!==n&&"TEXTAREA"!==n||t.readOnly)||(o=!1),o},unbind:function(e){if(e){if(Array.isArray(e))e.forEach(function(e){e.key&&f(e)});else if("object"==typeof e)e.key&&f(e);else if("string"==typeof e){for(var t=arguments.length,n=Array(1<t?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];var r=n[0],i=n[1];"function"==typeof r&&(i=r,r=""),f({key:e,scope:r,method:i,splitKey:"+"})}}else Object.keys(g).forEach(function(e){return delete g[e]})}};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(b[a]=r[a]);if("undefined"!=typeof window){var c=window.hotkeys;b.noConflict=function(e){return e&&window.hotkeys===b&&(window.hotkeys=c),b},window.hotkeys=b}return b});
if (process.env.NODE_ENV === 'production') {
// eslint-disable-next-line global-require
module.exports = require('./dist/hotkeys.common.min.js');
} else {
// eslint-disable-next-line global-require
module.exports = require('./dist/hotkeys.common.js');
}
{
"name": "hotkeys-js",
"description": "A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.",
"version": "3.7.6",
"version": "3.8.0",
"main": "index.js",

@@ -11,10 +11,9 @@ "types": "index.d.ts",

"deploy": "node scripts/build.js && npm run doc:build && gh-pages -d doc",
"build": "node scripts/build.js && npm run doc:build && npm run lint",
"build": "node scripts/build.js && npm run doc && npm run lint",
"watch": "node scripts/watch.js",
"pretest": "npm run build",
"test": "jest --coverage",
"test": "jest --coverage --detectOpenHandles",
"test:watch": "jest --watch",
"doc": "npm run doc:dev",
"doc:dev": "cross-env NODE_ENV=development parcel website/index.html --out-dir doc --no-cache",
"doc:build": "rimraf doc && cross-env NODE_ENV=production parcel build website/index.html --out-dir doc --public-url ./ --no-cache --no-source-maps"
"doc": "cross-env PUBLIC_URL=. ENTRYDIR=website kkt build",
"doc:dev": "cross-env PUBLIC_URL=. ENTRYDIR=website kkt start"
},

@@ -54,9 +53,9 @@ "files": [

"devDependencies": {
"@babel/core": "7.9.0",
"@babel/plugin-external-helpers": "7.8.3",
"@babel/plugin-transform-runtime": "7.9.0",
"@babel/preset-env": "7.9.0",
"@babel/preset-react": "7.9.4",
"@kkt/loader-less": "5.8.0",
"@kkt/loader-raw": "5.8.0",
"@uiw/react-github-corners": "1.1.3",
"autoprefixer": "9.7.5",
"@uiw/react-mac-keyboard": "1.0.5",
"@uiw/react-markdown-preview": "1.0.3",
"@uiw/react-shields": "1.1.0",
"@uiw/reset.css": "1.0.3",
"babel-eslint": "10.1.0",

@@ -67,27 +66,34 @@ "bannerjs": "1.0.7",

"cross-env": "7.0.2",
"eslint": "6.8.0",
"eslint": "7.0.0",
"eslint-config-airbnb": "18.1.0",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react": "7.20.0",
"gh-pages": "2.2.0",
"highlight.js": "9.18.1",
"husky": "4.2.3",
"jest": "25.2.3",
"less": "3.11.1",
"parcel-bundler": "1.12.4",
"parcel-plugin-markdown-string": "1.4.2",
"postcss-modules": "1.5.0",
"jest": "25.2.7",
"kkt": "5.8.0",
"puppeteer": "2.1.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-markdown": "4.3.1",
"rimraf": "3.0.2",
"rollup": "2.2.0",
"rollup": "2.10.2",
"rollup-plugin-babel": "4.4.0",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-node-resolve": "5.2.0",
"uglify-js": "3.8.0",
"uglify-js": "3.8.1",
"zlib": "1.0.5"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

@@ -7,5 +7,5 @@ # Hotkeys

HotKeys.js is an input capture library with some very special features, it is easy to pick up and use, has a reasonable footprint (~3kb) (gzipped: 1.73kb), and has no dependencies. It should not interfere with any JavaScript libraries or frameworks. Official document [demo preview](http://jaywcjlove.github.io/hotkeys). [More examples](https://github.com/jaywcjlove/hotkeys/issues?q=label%3ADemo+).
HotKeys.js is an input capture library with some very special features, it is easy to pick up and use, has a reasonable footprint ([~3kb](https://bundlephobia.com/result?p=hotkeys-js)) (gzipped: 1.73kb), and has no dependencies. It should not interfere with any JavaScript libraries or frameworks. Official document [demo preview](http://jaywcjlove.github.io/hotkeys). [More examples](https://github.com/jaywcjlove/hotkeys/issues?q=label%3ADemo+).
```shell
```bash
╭┈┈╮ ╭┈┈╮ ╭┈┈╮

@@ -22,3 +22,3 @@ ┆ ├┈┈..┈┈┈┈┈.┆ └┈╮┆ ├┈┈..┈┈┈┈┈..┈┈.┈┈..┈┈┈┈┈.

```shell
```bash
$ npm install hotkeys-js --save

@@ -95,3 +95,3 @@ ```

```
```js
hotkeys([keys:<String>], [option:[string|object|function]], [callback:<function>])

@@ -98,0 +98,0 @@ ```

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