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.8.7 to 3.8.8

35

dist/hotkeys.common.js

@@ -1,9 +0,8 @@

/*!
* hotkeys-js v3.8.7
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
/**!
* hotkeys-js v3.8.8
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
*
* Copyright (c) 2021 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
*
* Licensed under the MIT license.
* Copyright (c) 2022 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
* Licensed under the MIT license
*/

@@ -160,2 +159,4 @@

var winListendFocus = false; // window是否已经监听了focus事件
var _scope = 'all'; // 默认热键范围

@@ -312,11 +313,6 @@

var mods = len > 1 ? getMods(_modifier, unbindKeys) : [];
_handlers[keyCode] = _handlers[keyCode].map(function (record) {
_handlers[keyCode] = _handlers[keyCode].filter(function (record) {
// 通过函数判断,是否解除绑定,函数相等直接返回
var isMatchingMethod = method ? record.method === method : true;
if (isMatchingMethod && record.scope === scope && compareArray(record.mods, mods)) {
return {};
}
return record;
return !(isMatchingMethod && record.scope === scope && compareArray(record.mods, mods));
});

@@ -536,5 +532,10 @@ });

});
addEvent(window, 'focus', function () {
_downKeys = [];
});
if (!winListendFocus) {
winListendFocus = true;
addEvent(window, 'focus', function () {
_downKeys = [];
});
}
addEvent(element, 'keyup', function (e) {

@@ -541,0 +542,0 @@ dispatch(e);

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

/*! hotkeys-js v3.8.7 | MIT (c) 2021 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,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent&&e.attachEvent("on".concat(n),function(){t(window.event)})}function getMods(e,n){for(var t=n.slice(0,n.length-1),o=0;o<t.length;o++)t[o]=e[t[o].toLowerCase()];return t}function getKeys(e){for(var n=(e=(e="string"!=typeof e?"":e).replace(/\s/g,"")).split(","),t=n.lastIndexOf("");0<=t;)n[t-1]+=",",n.splice(t,1),t=n.lastIndexOf("");return n}function compareArray(e,n){for(var t=e.length<n.length?n:e,o=e.length<n.length?e:n,s=!0,d=0;d<t.length;d++)~o.indexOf(t[d])||(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,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"\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 n=e.target||e.srcElement,e=n.tagName;return!n.isContentEditable&&("INPUT"!==e&&"TEXTAREA"!==e&&"SELECT"!==e||n.readOnly)?!0:!1}function isPressed(e){return"string"==typeof e&&(e=code(e)),!!~_downKeys.indexOf(e)}function deleteScope(e,n){var t,o,s;for(s in e=e||getScope(),_handlers)if(Object.prototype.hasOwnProperty.call(_handlers,s))for(t=_handlers[s],o=0;o<t.length;)t[o].scope===e?t.splice(o,1):o++;getScope()===e&&setScope(n||"all")}function clearModifier(e){var n=e.keyCode||e.which||e.charCode,t=_downKeys.indexOf(n);if(t<0||_downKeys.splice(t,1),e.key&&"meta"==e.key.toLowerCase()&&_downKeys.splice(0,_downKeys.length),(n=93===n||224===n?91:n)in _mods)for(var o in _mods[n]=!1,_modifier)_modifier[o]===n&&(hotkeys[o]=!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 n=arguments.length,t=Array(1<n?n-1:0),o=1;o<n;o++)t[o-1]=arguments[o];var s=t[0],d=t[1];"function"==typeof s&&(d=s,s=""),eachUnbind({key:e,scope:s,method:d,splitKey:"+"})}}else Object.keys(_handlers).forEach(function(e){return delete _handlers[e]})}var eachUnbind=function(e){var s=e.scope,d=e.method,n=e.splitKey,r=void 0===n?"+":n;getKeys(e.key).forEach(function(e){var n,t=e.split(r),o=t.length,e=t[o-1],e="*"===e?"*":code(e);_handlers[e]&&(s=s||getScope(),n=1<o?getMods(_modifier,t):[],_handlers[e]=_handlers[e].map(function(e){return d&&e.method!==d||e.scope!==s||!compareArray(e.mods,n)?e:{}}))})};function eventHandler(e,n,t){var o;if(n.scope===t||"all"===n.scope){for(var s in o=0<n.mods.length,_mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(!_mods[s]&&~n.mods.indexOf(+s)||_mods[s]&&!~n.mods.indexOf(+s))&&(o=!1);(0!==n.mods.length||_mods[16]||_mods[18]||_mods[17]||_mods[91])&&!o&&"*"!==n.shortcut||!1===n.method(e,n)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function dispatch(t){var e=_handlers["*"],n=t.keyCode||t.which||t.charCode;if(hotkeys.filter.call(this,t)){if(~_downKeys.indexOf(n=93===n||224===n?91:n)||229===n||_downKeys.push(n),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var n=modifierMap[e];t[e]&&!~_downKeys.indexOf(n)?_downKeys.push(n):!t[e]&&~_downKeys.indexOf(n)?_downKeys.splice(_downKeys.indexOf(n),1):"metaKey"===e&&t[e]&&3===_downKeys.length&&(t.ctrlKey||t.shiftKey||t.altKey||(_downKeys=_downKeys.slice(_downKeys.indexOf(n))))}),n in _mods){for(var o in _mods[n]=!0,_modifier)_modifier[o]===n&&(hotkeys[o]=!0);if(!e)return}for(var s in _mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(_mods[s]=t[modifierMap[s]]);t.getModifierState&&(!t.altKey||t.ctrlKey)&&t.getModifierState("AltGraph")&&(~_downKeys.indexOf(17)||_downKeys.push(17),~_downKeys.indexOf(18)||_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);var d=getScope();if(e)for(var r=0;r<e.length;r++)e[r].scope===d&&("keydown"===t.type&&e[r].keydown||"keyup"===t.type&&e[r].keyup)&&eventHandler(t,e[r],d);if(n in _handlers)for(var i=0;i<_handlers[n].length;i++)if(("keydown"===t.type&&_handlers[n][i].keydown||"keyup"===t.type&&_handlers[n][i].keyup)&&_handlers[n][i].key){for(var a=_handlers[n][i],c=a.key.split(a.splitKey),l=[],y=0;y<c.length;y++)l.push(code(c[y]));l.sort().join("")===_downKeys.sort().join("")&&eventHandler(t,a,d)}}}function isElementBind(e){return!!~elementHasBindEvent.indexOf(e)}function hotkeys(e,n,t){_downKeys=[];var o=getKeys(e),s=[],d="all",r=document,i=0,a=!1,c=!0,l="+";for(void 0===t&&"function"==typeof n&&(t=n),"[object Object]"===Object.prototype.toString.call(n)&&(n.scope&&(d=n.scope),n.element&&(r=n.element),n.keyup&&(a=n.keyup),void 0!==n.keydown&&(c=n.keydown),"string"==typeof n.splitKey&&(l=n.splitKey)),"string"==typeof n&&(d=n);i<o.length;i++)s=[],1<(e=o[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:d,mods:s,shortcut:o[i],method:t,key:o[i],splitKey:l});void 0!==r&&!isElementBind(r)&&window&&(elementHasBindEvent.push(r),addEvent(r,"keydown",function(e){dispatch(e)}),addEvent(window,"focus",function(){_downKeys=[]}),addEvent(r,"keyup",function(e){dispatch(e),clearModifier(e)}))}var a,_hotkeys,_api={setScope:setScope,getScope:getScope,deleteScope:deleteScope,getPressedKeyCodes:getPressedKeyCodes,isPressed:isPressed,filter:filter,unbind:unbind};for(a in _api)Object.prototype.hasOwnProperty.call(_api,a)&&(hotkeys[a]=_api[a]);"undefined"!=typeof window&&(_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.8 | MIT © 2022 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,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent&&e.attachEvent("on".concat(n),function(){t(window.event)})}function getMods(e,n){for(var t=n.slice(0,n.length-1),o=0;o<t.length;o++)t[o]=e[t[o].toLowerCase()];return t}function getKeys(e){for(var n=(e=(e="string"!=typeof e?"":e).replace(/\s/g,"")).split(","),t=n.lastIndexOf("");0<=t;)n[t-1]+=",",n.splice(t,1),t=n.lastIndexOf("");return n}function compareArray(e,n){for(var t=e.length<n.length?n:e,o=e.length<n.length?e:n,s=!0,i=0;i<t.length;i++)~o.indexOf(t[i])||(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,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"\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=[],winListendFocus=!1,_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 e=e.target||e.srcElement,n=e.tagName;return!e.isContentEditable&&("INPUT"!==n&&"TEXTAREA"!==n&&"SELECT"!==n||e.readOnly)?!0:!1}function isPressed(e){return"string"==typeof e&&(e=code(e)),!!~_downKeys.indexOf(e)}function deleteScope(e,n){var t,o,s;for(s in e=e||getScope(),_handlers)if(Object.prototype.hasOwnProperty.call(_handlers,s))for(t=_handlers[s],o=0;o<t.length;)t[o].scope===e?t.splice(o,1):o++;getScope()===e&&setScope(n||"all")}function clearModifier(e){var n=e.keyCode||e.which||e.charCode,t=_downKeys.indexOf(n);if(t<0||_downKeys.splice(t,1),e.key&&"meta"==e.key.toLowerCase()&&_downKeys.splice(0,_downKeys.length),(n=93!==n&&224!==n?n:91)in _mods)for(var o in _mods[n]=!1,_modifier)_modifier[o]===n&&(hotkeys[o]=!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 n=arguments.length,t=Array(1<n?n-1:0),o=1;o<n;o++)t[o-1]=arguments[o];var s=t[0],i=t[1];"function"==typeof s&&(i=s,s=""),eachUnbind({key:e,scope:s,method:i,splitKey:"+"})}}else Object.keys(_handlers).forEach(function(e){return delete _handlers[e]})}var eachUnbind=function(e){var s=e.scope,i=e.method,n=e.splitKey,d=void 0===n?"+":n;getKeys(e.key).forEach(function(e){var n,e=e.split(d),t=e.length,o=e[t-1],o="*"===o?"*":code(o);_handlers[o]&&(s=s||getScope(),n=1<t?getMods(_modifier,e):[],_handlers[o]=_handlers[o].filter(function(e){return!((!i||e.method===i)&&e.scope===s&&compareArray(e.mods,n))}))})};function eventHandler(e,n,t){var o;if(n.scope===t||"all"===n.scope){for(var s in o=0<n.mods.length,_mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(!_mods[s]&&~n.mods.indexOf(+s)||_mods[s]&&!~n.mods.indexOf(+s))&&(o=!1);(0!==n.mods.length||_mods[16]||_mods[18]||_mods[17]||_mods[91])&&!o&&"*"!==n.shortcut||!1===n.method(e,n)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function dispatch(t){var e=_handlers["*"],n=t.keyCode||t.which||t.charCode;if(hotkeys.filter.call(this,t)){if(~_downKeys.indexOf(n=93!==n&&224!==n?n:91)||229===n||_downKeys.push(n),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var n=modifierMap[e];t[e]&&!~_downKeys.indexOf(n)?_downKeys.push(n):!t[e]&&~_downKeys.indexOf(n)?_downKeys.splice(_downKeys.indexOf(n),1):"metaKey"!==e||!t[e]||3!==_downKeys.length||t.ctrlKey||t.shiftKey||t.altKey||(_downKeys=_downKeys.slice(_downKeys.indexOf(n)))}),n in _mods){for(var o in _mods[n]=!0,_modifier)_modifier[o]===n&&(hotkeys[o]=!0);if(!e)return}for(var s in _mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(_mods[s]=t[modifierMap[s]]);t.getModifierState&&(!t.altKey||t.ctrlKey)&&t.getModifierState("AltGraph")&&(~_downKeys.indexOf(17)||_downKeys.push(17),~_downKeys.indexOf(18)||_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);var i=getScope();if(e)for(var d=0;d<e.length;d++)e[d].scope===i&&("keydown"===t.type&&e[d].keydown||"keyup"===t.type&&e[d].keyup)&&eventHandler(t,e[d],i);if(n in _handlers)for(var r=0;r<_handlers[n].length;r++)if(("keydown"===t.type&&_handlers[n][r].keydown||"keyup"===t.type&&_handlers[n][r].keyup)&&_handlers[n][r].key){for(var a=_handlers[n][r],c=a.key.split(a.splitKey),l=[],y=0;y<c.length;y++)l.push(code(c[y]));l.sort().join("")===_downKeys.sort().join("")&&eventHandler(t,a,i)}}}function isElementBind(e){return!!~elementHasBindEvent.indexOf(e)}function hotkeys(e,n,t){_downKeys=[];var o=getKeys(e),s=[],i="all",d=document,r=0,a=!1,c=!0,l="+";for(void 0===t&&"function"==typeof n&&(t=n),"[object Object]"===Object.prototype.toString.call(n)&&(n.scope&&(i=n.scope),n.element&&(d=n.element),n.keyup&&(a=n.keyup),void 0!==n.keydown&&(c=n.keydown),"string"==typeof n.splitKey&&(l=n.splitKey)),"string"==typeof n&&(i=n);r<o.length;r++)s=[],1<(e=o[r].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:i,mods:s,shortcut:o[r],method:t,key:o[r],splitKey:l});void 0!==d&&!isElementBind(d)&&window&&(elementHasBindEvent.push(d),addEvent(d,"keydown",function(e){dispatch(e)}),winListendFocus||(winListendFocus=!0,addEvent(window,"focus",function(){_downKeys=[]})),addEvent(d,"keyup",function(e){dispatch(e),clearModifier(e)}))}var a,_hotkeys,_api={setScope:setScope,getScope:getScope,deleteScope:deleteScope,getPressedKeyCodes:getPressedKeyCodes,isPressed:isPressed,filter:filter,unbind:unbind};for(a in _api)Object.prototype.hasOwnProperty.call(_api,a)&&(hotkeys[a]=_api[a]);"undefined"!=typeof window&&(_hotkeys=window.hotkeys,hotkeys.noConflict=function(e){return e&&window.hotkeys===hotkeys&&(window.hotkeys=_hotkeys),hotkeys},window.hotkeys=hotkeys),module.exports=hotkeys;

@@ -1,9 +0,8 @@

/*!
* hotkeys-js v3.8.7
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
/**!
* hotkeys-js v3.8.8
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
*
* Copyright (c) 2021 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
*
* Licensed under the MIT license.
* Copyright (c) 2022 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
* Licensed under the MIT license
*/

@@ -158,2 +157,4 @@

var winListendFocus = false; // window是否已经监听了focus事件
var _scope = 'all'; // 默认热键范围

@@ -310,11 +311,6 @@

var mods = len > 1 ? getMods(_modifier, unbindKeys) : [];
_handlers[keyCode] = _handlers[keyCode].map(function (record) {
_handlers[keyCode] = _handlers[keyCode].filter(function (record) {
// 通过函数判断,是否解除绑定,函数相等直接返回
var isMatchingMethod = method ? record.method === method : true;
if (isMatchingMethod && record.scope === scope && compareArray(record.mods, mods)) {
return {};
}
return record;
return !(isMatchingMethod && record.scope === scope && compareArray(record.mods, mods));
});

@@ -534,5 +530,10 @@ });

});
addEvent(window, 'focus', function () {
_downKeys = [];
});
if (!winListendFocus) {
winListendFocus = true;
addEvent(window, 'focus', function () {
_downKeys = [];
});
}
addEvent(element, 'keyup', function (e) {

@@ -575,2 +576,2 @@ dispatch(e);

export default hotkeys;
export { hotkeys as default };

@@ -1,9 +0,8 @@

/*!
* hotkeys-js v3.8.7
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
/**!
* hotkeys-js v3.8.8
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
*
* Copyright (c) 2021 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
*
* Licensed under the MIT license.
* Copyright (c) 2022 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
* Licensed under the MIT license
*/

@@ -15,3 +14,3 @@

(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.hotkeys = factory());
}(this, (function () { 'use strict';
})(this, (function () { 'use strict';

@@ -165,2 +164,4 @@ var isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; // 绑定事件

var winListendFocus = false; // window是否已经监听了focus事件
var _scope = 'all'; // 默认热键范围

@@ -317,11 +318,6 @@

var mods = len > 1 ? getMods(_modifier, unbindKeys) : [];
_handlers[keyCode] = _handlers[keyCode].map(function (record) {
_handlers[keyCode] = _handlers[keyCode].filter(function (record) {
// 通过函数判断,是否解除绑定,函数相等直接返回
var isMatchingMethod = method ? record.method === method : true;
if (isMatchingMethod && record.scope === scope && compareArray(record.mods, mods)) {
return {};
}
return record;
return !(isMatchingMethod && record.scope === scope && compareArray(record.mods, mods));
});

@@ -541,5 +537,10 @@ });

});
addEvent(window, 'focus', function () {
_downKeys = [];
});
if (!winListendFocus) {
winListendFocus = true;
addEvent(window, 'focus', function () {
_downKeys = [];
});
}
addEvent(element, 'keyup', function (e) {

@@ -584,2 +585,2 @@ dispatch(e);

})));
}));

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

/*! hotkeys-js v3.8.7 | MIT (c) 2021 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="undefined"!=typeof globalThis?globalThis:e||self).hotkeys=t()}(this,function(){"use strict";var e="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function u(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 d(e){for(var t=(e=(e="string"!=typeof 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,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"\u21ea":20,",":188,".":190,"/":191,"`":192,"-":e?173:189,"=":e?61:187,";":e?59:186,"'":222,"[":219,"]":221,"\\":220},y={"\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},m={16:!1,18:!1,17:!1,91:!1},g={},n=1;n<20;n++)t["f".concat(n)]=111+n;var v=[],o="all",w=[],k=function(e){return t[e.toLowerCase()]||y[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function r(e){o=e||"all"}function O(){return o||"all"}function f(e){var i=e.scope,r=e.method,t=e.splitKey,f=void 0===t?"+":t;d(e.key).forEach(function(e){var t,n=e.split(f),o=n.length,e=n[o-1],e="*"===e?"*":k(e);g[e]&&(i=i||O(),t=1<o?p(y,n):[],g[e]=g[e].map(function(e){return r&&e.method!==r||e.scope!==i||!function(e,t){for(var n=e.length<t.length?t:e,o=e.length<t.length?e:t,i=!0,r=0;r<n.length;r++)~o.indexOf(n[r])||(i=!1);return i}(e.mods,t)?e:{}}))})}function K(e,t,n){var o;if(t.scope===n||"all"===t.scope){for(var i in o=0<t.mods.length,m)Object.prototype.hasOwnProperty.call(m,i)&&(!m[i]&&~t.mods.indexOf(+i)||m[i]&&!~t.mods.indexOf(+i))&&(o=!1);(0!==t.mods.length||m[16]||m[18]||m[17]||m[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(~v.indexOf(t=93===t||224===t?91:t)||229===t||v.push(t),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var t=h[e];n[e]&&!~v.indexOf(t)?v.push(t):!n[e]&&~v.indexOf(t)?v.splice(v.indexOf(t),1):"metaKey"===e&&n[e]&&3===v.length&&(n.ctrlKey||n.shiftKey||n.altKey||(v=v.slice(v.indexOf(t))))}),t in m){for(var o in m[t]=!0,y)y[o]===t&&(x[o]=!0);if(!e)return}for(var i in m)Object.prototype.hasOwnProperty.call(m,i)&&(m[i]=n[h[i]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~v.indexOf(17)||v.push(17),~v.indexOf(18)||v.push(18),m[17]=!0,m[18]=!0);var r=O();if(e)for(var f=0;f<e.length;f++)e[f].scope===r&&("keydown"===n.type&&e[f].keydown||"keyup"===n.type&&e[f].keyup)&&K(n,e[f],r);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=[],u=0;u<l.length;u++)s.push(k(l[u]));s.sort().join("")===v.sort().join("")&&K(n,c,r)}}}function x(e,t,n){v=[];var o=d(e),i=[],r="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&&(r=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&&(r=t);a<o.length;a++)i=[],1<(e=o[a].split(s)).length&&(i=p(y,e)),(e="*"===(e=e[e.length-1])?"*":k(e))in g||(g[e]=[]),g[e].push({keyup:c,keydown:l,scope:r,mods:i,shortcut:o[a],method:n,key:o[a],splitKey:s});void 0!==f&&(t=f,!~w.indexOf(t))&&window&&(w.push(f),u(f,"keydown",function(e){b(e)}),u(window,"focus",function(){v=[]}),u(f,"keyup",function(e){b(e),function(e){var t=e.keyCode||e.which||e.charCode,n=v.indexOf(t);if(n<0||v.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&v.splice(0,v.length),(t=93===t||224===t?91:t)in m)for(var o in m[t]=!1,y)y[o]===t&&(x[o]=!1)}(e)}))}var i,a,c={setScope:r,getScope:O,deleteScope:function(e,t){var n,o,i;for(i in e=e||O(),g)if(Object.prototype.hasOwnProperty.call(g,i))for(n=g[i],o=0;o<n.length;)n[o].scope===e?n.splice(o,1):o++;O()===e&&r(t||"all")},getPressedKeyCodes:function(){return v.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=k(e)),!!~v.indexOf(e)},filter:function(e){var t=e.target||e.srcElement,e=t.tagName;return!t.isContentEditable&&("INPUT"!==e&&"TEXTAREA"!==e&&"SELECT"!==e||t.readOnly)?!0:!1},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 i=n[0],r=n[1];"function"==typeof i&&(r=i,i=""),f({key:e,scope:i,method:r,splitKey:"+"})}}else Object.keys(g).forEach(function(e){return delete g[e]})}};for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(x[i]=c[i]);return"undefined"!=typeof window&&(a=window.hotkeys,x.noConflict=function(e){return e&&window.hotkeys===x&&(window.hotkeys=a),x},window.hotkeys=x),x});
/*! hotkeys-js v3.8.8 | MIT © 2022 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="undefined"!=typeof globalThis?globalThis:e||self).hotkeys=t()}(this,function(){"use strict";var e="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function u(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 d(e){for(var t=(e=(e="string"!=typeof 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,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"\u21ea":20,",":188,".":190,"/":191,"`":192,"-":e?173:189,"=":e?61:187,";":e?59:186,"'":222,"[":219,"]":221,"\\":220},y={"\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},m={16:!1,18:!1,17:!1,91:!1},g={},n=1;n<20;n++)t["f".concat(n)]=111+n;var v=[],w=!1,o="all",k=[],O=function(e){return t[e.toLowerCase()]||y[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function r(e){o=e||"all"}function K(){return o||"all"}function f(e){var i=e.scope,r=e.method,t=e.splitKey,f=void 0===t?"+":t;d(e.key).forEach(function(e){var t,e=e.split(f),n=e.length,o=e[n-1],o="*"===o?"*":O(o);g[o]&&(i=i||K(),t=1<n?p(y,e):[],g[o]=g[o].filter(function(e){return!((!r||e.method===r)&&e.scope===i&&function(e,t){for(var n=e.length<t.length?t:e,o=e.length<t.length?e:t,i=!0,r=0;r<n.length;r++)~o.indexOf(n[r])||(i=!1);return i}(e.mods,t))}))})}function b(e,t,n){var o;if(t.scope===n||"all"===t.scope){for(var i in o=0<t.mods.length,m)Object.prototype.hasOwnProperty.call(m,i)&&(!m[i]&&~t.mods.indexOf(+i)||m[i]&&!~t.mods.indexOf(+i))&&(o=!1);(0!==t.mods.length||m[16]||m[18]||m[17]||m[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(_.filter.call(this,n)){if(~v.indexOf(t=93!==t&&224!==t?t:91)||229===t||v.push(t),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var t=h[e];n[e]&&!~v.indexOf(t)?v.push(t):!n[e]&&~v.indexOf(t)?v.splice(v.indexOf(t),1):"metaKey"!==e||!n[e]||3!==v.length||n.ctrlKey||n.shiftKey||n.altKey||(v=v.slice(v.indexOf(t)))}),t in m){for(var o in m[t]=!0,y)y[o]===t&&(_[o]=!0);if(!e)return}for(var i in m)Object.prototype.hasOwnProperty.call(m,i)&&(m[i]=n[h[i]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~v.indexOf(17)||v.push(17),~v.indexOf(18)||v.push(18),m[17]=!0,m[18]=!0);var r=K();if(e)for(var f=0;f<e.length;f++)e[f].scope===r&&("keydown"===n.type&&e[f].keydown||"keyup"===n.type&&e[f].keyup)&&b(n,e[f],r);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 l=g[t][a],c=l.key.split(l.splitKey),s=[],u=0;u<c.length;u++)s.push(O(c[u]));s.sort().join("")===v.sort().join("")&&b(n,l,r)}}}function _(e,t,n){v=[];var o=d(e),i=[],r="all",f=document,a=0,l=!1,c=!0,s="+";for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(r=t.scope),t.element&&(f=t.element),t.keyup&&(l=t.keyup),void 0!==t.keydown&&(c=t.keydown),"string"==typeof t.splitKey&&(s=t.splitKey)),"string"==typeof t&&(r=t);a<o.length;a++)i=[],1<(e=o[a].split(s)).length&&(i=p(y,e)),(e="*"===(e=e[e.length-1])?"*":O(e))in g||(g[e]=[]),g[e].push({keyup:l,keydown:c,scope:r,mods:i,shortcut:o[a],method:n,key:o[a],splitKey:s});void 0!==f&&(t=f,!~k.indexOf(t))&&window&&(k.push(f),u(f,"keydown",function(e){x(e)}),w||(w=!0,u(window,"focus",function(){v=[]})),u(f,"keyup",function(e){x(e);var t=e.keyCode||e.which||e.charCode,n=v.indexOf(t);if(n<0||v.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&v.splice(0,v.length),(t=93!==t&&224!==t?t:91)in m)for(var o in m[t]=!1,y)y[o]===t&&(_[o]=!1)}))}var i,a,l={setScope:r,getScope:K,deleteScope:function(e,t){var n,o,i;for(i in e=e||K(),g)if(Object.prototype.hasOwnProperty.call(g,i))for(n=g[i],o=0;o<n.length;)n[o].scope===e?n.splice(o,1):o++;K()===e&&r(t||"all")},getPressedKeyCodes:function(){return v.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=O(e)),!!~v.indexOf(e)},filter:function(e){var t=(e=e.target||e.srcElement).tagName;return!e.isContentEditable&&("INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t||e.readOnly)?!0:!1},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 i=n[0],r=n[1];"function"==typeof i&&(r=i,i=""),f({key:e,scope:i,method:r,splitKey:"+"})}}else Object.keys(g).forEach(function(e){return delete g[e]})}};for(i in l)Object.prototype.hasOwnProperty.call(l,i)&&(_[i]=l[i]);return"undefined"!=typeof window&&(a=window.hotkeys,_.noConflict=function(e){return e&&window.hotkeys===_&&(window.hotkeys=a),_},window.hotkeys=_),_});
{
"name": "hotkeys-js",
"description": "A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.",
"version": "3.8.7",
"version": "3.8.8",
"main": "index.js",

@@ -53,32 +53,32 @@ "types": "index.d.ts",

"devDependencies": {
"@kkt/less-modules": "6.9.0",
"@kkt/raw-modules": "6.9.0",
"@kkt/scope-plugin-options": "6.9.0",
"@uiw/react-github-corners": "1.4.0",
"@uiw/react-mac-keyboard": "1.0.5",
"@uiw/react-markdown-preview": "3.1.1",
"@uiw/react-shields": "1.1.1",
"@uiw/reset.css": "1.0.4",
"babel-eslint": "10.1.0",
"bannerjs": "1.0.7",
"classnames": "2.3.1",
"colors-cli": "1.0.27",
"eslint": "7.28.0",
"eslint-config-airbnb": "18.2.1",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-react": "7.24.0",
"husky": "4.2.3",
"kkt": "6.9.0",
"jest": "27.0.4",
"puppeteer": "10.0.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"rimraf": "3.0.2",
"rollup": "2.51.1",
"@rollup/plugin-babel": "5.3.0",
"@rollup/plugin-commonjs": "19.0.0",
"@rollup/plugin-node-resolve": "13.0.0",
"uglify-js": "3.13.9",
"zlib": "1.0.5"
"@babel/eslint-parser": "~7.17.0",
"@kkt/less-modules": "~7.1.1",
"@kkt/raw-modules": "~7.1.1",
"@kkt/scope-plugin-options": "~7.1.1",
"@uiw/react-github-corners": "~1.5.14",
"@uiw/react-mac-keyboard": "~1.1.4",
"@uiw/react-markdown-preview": "~4.0.5",
"@uiw/react-shields": "~1.1.2",
"@uiw/reset.css": "~1.0.6",
"bannerjs": "~2.1.0",
"classnames": "~2.3.1",
"colors-cli": "~1.0.28",
"eslint": "~8.12.0",
"eslint-config-airbnb": "~19.0.4",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-jsx-a11y": "~6.5.1",
"eslint-plugin-react": "~7.29.4",
"husky": "~4.2.3",
"kkt": "~7.1.5",
"jest": "~27.5.1",
"puppeteer": "~13.5.2",
"react": "~17.0.2",
"react-dom": "~17.0.2",
"rimraf": "~3.0.2",
"rollup": "~2.70.1",
"@rollup/plugin-babel": "~5.3.1",
"@rollup/plugin-commonjs": "~21.0.3",
"@rollup/plugin-node-resolve": "~13.1.3",
"uglify-js": "~3.15.3",
"zlib": "~1.0.5"
},

@@ -85,0 +85,0 @@ "browserslist": {

@@ -5,3 +5,10 @@ # Hotkeys

[![](https://img.shields.io/github/issues/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/issues) [![](https://img.shields.io/github/forks/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/network) [![](https://img.shields.io/github/stars/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/stargazers) [![](https://img.shields.io/github/release/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/releases) ![](http://jaywcjlove.github.io/sb/status/no-dependencies.svg) [![Build Status](https://www.travis-ci.org/jaywcjlove/hotkeys.svg?branch=master)](https://www.travis-ci.org/jaywcjlove/hotkeys) [![Coverage Status](https://coveralls.io/repos/github/jaywcjlove/hotkeys/badge.svg?branch=master)](https://coveralls.io/github/jaywcjlove/hotkeys?branch=master) [![jaywcjlove/hotkeys](https://jaywcjlove.github.io/sb/lang/chinese.svg)](./README-zh.md) [![jaywcjlove/hotkeys](https://jaywcjlove.github.io/sb/ico/gitee.svg)](https://gitee.com/jaywcjlove/hotkeys)
[![CDN jsdelivr](https://data.jsdelivr.com/v1/package/npm/hotkeys-js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/hotkeys-js)
[![](https://img.shields.io/npm/dm/hotkeys-js?logo=npm)](https://www.npmjs.com/package/hotkeys-js)
[![](https://img.shields.io/github/stars/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/stargazers)
![no dependencies](http://jaywcjlove.github.io/sb/status/no-dependencies.svg)
[![GitHub Actions CI](https://github.com/jaywcjlove/hotkeys/actions/workflows/ci.yml/badge.svg)](https://github.com/jaywcjlove/hotkeys/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/jaywcjlove/hotkeys/badge.svg?branch=master)](https://coveralls.io/github/jaywcjlove/hotkeys?branch=master)
[![jaywcjlove/hotkeys](https://jaywcjlove.github.io/sb/lang/chinese.svg)](https://github.com/jaywcjlove/hotkeys/blob/master/README-zh.md)
[![jaywcjlove/hotkeys](https://jaywcjlove.github.io/sb/ico/gitee.svg)](https://gitee.com/jaywcjlove/hotkeys)

@@ -80,3 +87,3 @@ 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+).

The following special keys can be used for shortcuts: backspace, tab, clear, enter, return, esc, escape, space, up, down, left, right, home, end, pageup, pagedown, del, delete and f1 through f19.
The following special keys can be used for shortcuts: backspace, tab, clear, enter, return, esc, escape, space, up, down, left, right, home, end, pageup, pagedown, del, delete, f1 through f19, num_0 through num_9, num_multiply, num_add, num_enter, num_subtract, num_decimal, num_divide.

@@ -326,4 +333,5 @@ `⌘` Command()

hotkeys.filter = function(event) {
var tagName = (event.target || event.srcElement).tagName;
return !(tagName.isContentEditable || tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
var target = event.target || event.srcElement;
var tagName = target.tagName;
return !(target.isContentEditable || tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
}

@@ -384,4 +392,14 @@

## Contributors
As always, thanks to our amazing contributors!
<a href="https://github.com/jaywcjlove/hotkeys/graphs/contributors">
<img src="https://jaywcjlove.github.io/hotkeys/CONTRIBUTORS.svg" />
</a>
Made with [github-action-contributors](https://github.com/jaywcjlove/github-action-contributors).
## License
[MIT © Kenny Wong](./LICENSE)
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