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.11.2 to 3.12.0

35

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

@@ -192,2 +192,22 @@ *

}
function getAllKeyCodes() {
var result = [];
Object.keys(_handlers).forEach(function (k) {
_handlers[k].forEach(function (_ref) {
var key = _ref.key,
scope = _ref.scope,
mods = _ref.mods,
shortcut = _ref.shortcut;
result.push({
scope: scope,
shortcut: shortcut,
mods: mods,
keys: key.split('+').map(function (v) {
return code(v);
})
});
});
});
return result;
}

@@ -295,8 +315,8 @@ // 表单控件控件判断 返回 Boolean

// 解除绑定某个范围的快捷键
var eachUnbind = function eachUnbind(_ref) {
var key = _ref.key,
scope = _ref.scope,
method = _ref.method,
_ref$splitKey = _ref.splitKey,
splitKey = _ref$splitKey === void 0 ? '+' : _ref$splitKey;
var eachUnbind = function eachUnbind(_ref2) {
var key = _ref2.key,
scope = _ref2.scope,
method = _ref2.method,
_ref2$splitKey = _ref2.splitKey,
splitKey = _ref2$splitKey === void 0 ? '+' : _ref2$splitKey;
var multipleKeys = getKeys(key);

@@ -553,2 +573,3 @@ multipleKeys.forEach(function (originKey) {

getPressedKeyCodes: getPressedKeyCodes,
getAllKeyCodes: getAllKeyCodes,
isPressed: isPressed,

@@ -555,0 +576,0 @@ filter: filter,

4

dist/hotkeys.common.min.js

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

/*! hotkeys-js v3.11.2 | MIT © 2023 kenny wong <wowohoo@qq.com> https://jaywcjlove.github.io/hotkeys-js */
"use strict";var isff="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function addEvent(e,n,t,o){e.addEventListener?e.addEventListener(n,t,o):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,r=!0,i=0;i<t.length;i++)~o.indexOf(t[i])||(r=!1);return r}for(var _keyMap={backspace:8,"\u232b":8,tab:9,clear:12,enter:13,"\u21a9":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)},getKey=function(n){return Object.keys(_keyMap).find(function(e){return _keyMap[e]===n})},getModifier=function(n){return Object.keys(_modifier).find(function(e){return _modifier[e]===n})};function setScope(e){_scope=e||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function getPressedKeyString(){return _downKeys.map(function(e){return getKey(e)||getModifier(e)||String.fromCharCode(e)})}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,r;for(r in e=e||getScope(),_handlers)if(Object.prototype.hasOwnProperty.call(_handlers,r))for(t=_handlers[r],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(void 0===e)Object.keys(_handlers).forEach(function(e){return delete _handlers[e]});else 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 r=t[0],i=t[1];"function"==typeof r&&(i=r,r=""),eachUnbind({key:e,scope:r,method:i,splitKey:"+"})}}var eachUnbind=function(e){var r=e.scope,i=e.method,n=e.splitKey,s=void 0===n?"+":n;getKeys(e.key).forEach(function(e){var n,e=e.split(s),t=e.length,o=e[t-1],o="*"===o?"*":code(o);_handlers[o]&&(r=r||getScope(),n=1<t?getMods(_modifier,e):[],_handlers[o]=_handlers[o].filter(function(e){return!((!i||e.method===i)&&e.scope===r&&compareArray(e.mods,n))}))})};function eventHandler(e,n,t,o){var r;if(n.element===o&&(n.scope===t||"all"===n.scope)){for(var i in r=0<n.mods.length,_mods)Object.prototype.hasOwnProperty.call(_mods,i)&&(!_mods[i]&&~n.mods.indexOf(+i)||_mods[i]&&!~n.mods.indexOf(+i))&&(r=!1);(0!==n.mods.length||_mods[16]||_mods[18]||_mods[17]||_mods[91])&&!r&&"*"!==n.shortcut||(n.keys=[],n.keys=n.keys.concat(_downKeys),!1===n.method(e,n)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function dispatch(t,e){var n=_handlers["*"],o=t.keyCode||t.which||t.charCode;if(hotkeys.filter.call(this,t)){if(~_downKeys.indexOf(o=93!==o&&224!==o?o:91)||229===o||_downKeys.push(o),["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)))}),o in _mods){for(var r in _mods[o]=!0,_modifier)_modifier[r]===o&&(hotkeys[r]=!0);if(!n)return}for(var i in _mods)Object.prototype.hasOwnProperty.call(_mods,i)&&(_mods[i]=t[modifierMap[i]]);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 s=getScope();if(n)for(var d=0;d<n.length;d++)n[d].scope===s&&("keydown"===t.type&&n[d].keydown||"keyup"===t.type&&n[d].keyup)&&eventHandler(t,n[d],s,e);if(o in _handlers)for(var a=0;a<_handlers[o].length;a++)if(("keydown"===t.type&&_handlers[o][a].keydown||"keyup"===t.type&&_handlers[o][a].keyup)&&_handlers[o][a].key){for(var c=_handlers[o][a],f=c.key.split(c.splitKey),l=[],y=0;y<f.length;y++)l.push(code(f[y]));l.sort().join("")===_downKeys.sort().join("")&&eventHandler(t,c,s,e)}}}function isElementBind(e){return!!~elementHasBindEvent.indexOf(e)}function hotkeys(e,n,t){_downKeys=[];var o=getKeys(e),r=[],i="all",s=document,d=0,a=!1,c=!0,f="+",l=!1;for(void 0===t&&"function"==typeof n&&(t=n),"[object Object]"===Object.prototype.toString.call(n)&&(n.scope&&(i=n.scope),n.element&&(s=n.element),n.keyup&&(a=n.keyup),void 0!==n.keydown&&(c=n.keydown),void 0!==n.capture&&(l=n.capture),"string"==typeof n.splitKey&&(f=n.splitKey)),"string"==typeof n&&(i=n);d<o.length;d++)r=[],1<(e=o[d].split(f)).length&&(r=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:r,shortcut:o[d],method:t,key:o[d],splitKey:f,element:s});void 0!==s&&!isElementBind(s)&&window&&(elementHasBindEvent.push(s),addEvent(s,"keydown",function(e){dispatch(e,s)},l),winListendFocus||(winListendFocus=!0,addEvent(window,"focus",function(){_downKeys=[]},l)),addEvent(s,"keyup",function(e){dispatch(e,s),clearModifier(e)},l))}function trigger(n){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(_handlers).forEach(function(e){_handlers[e].filter(function(e){return e.scope===t&&e.shortcut===n}).forEach(function(e){e&&e.method&&e.method()})})}var a,_hotkeys,_api={getPressedKeyString:getPressedKeyString,setScope:setScope,getScope:getScope,deleteScope:deleteScope,getPressedKeyCodes:getPressedKeyCodes,isPressed:isPressed,filter:filter,trigger:trigger,unbind:unbind,keyMap:_keyMap,modifier:_modifier,modifierMap:modifierMap};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.12.0 | MIT © 2023 kenny wong <wowohoo@qq.com> https://jaywcjlove.github.io/hotkeys-js */
"use strict";var isff="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function addEvent(e,n,t,o){e.addEventListener?e.addEventListener(n,t,o):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,r=!0,s=0;s<t.length;s++)~o.indexOf(t[s])||(r=!1);return r}for(var _keyMap={backspace:8,"\u232b":8,tab:9,clear:12,enter:13,"\u21a9":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)},getKey=function(n){return Object.keys(_keyMap).find(function(e){return _keyMap[e]===n})},getModifier=function(n){return Object.keys(_modifier).find(function(e){return _modifier[e]===n})};function setScope(e){_scope=e||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function getPressedKeyString(){return _downKeys.map(function(e){return getKey(e)||getModifier(e)||String.fromCharCode(e)})}function getAllKeyCodes(){var t=[];return Object.keys(_handlers).forEach(function(e){_handlers[e].forEach(function(e){var n=e.key;t.push({scope:e.scope,shortcut:e.shortcut,mods:e.mods,keys:n.split("+").map(function(e){return code(e)})})})}),t}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,r;for(r in e=e||getScope(),_handlers)if(Object.prototype.hasOwnProperty.call(_handlers,r))for(t=_handlers[r],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(void 0===e)Object.keys(_handlers).forEach(function(e){return delete _handlers[e]});else 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 r=t[0],s=t[1];"function"==typeof r&&(s=r,r=""),eachUnbind({key:e,scope:r,method:s,splitKey:"+"})}}var eachUnbind=function(e){var r=e.scope,s=e.method,n=e.splitKey,i=void 0===n?"+":n;getKeys(e.key).forEach(function(e){var n,e=e.split(i),t=e.length,o=e[t-1],o="*"===o?"*":code(o);_handlers[o]&&(r=r||getScope(),n=1<t?getMods(_modifier,e):[],_handlers[o]=_handlers[o].filter(function(e){return!((!s||e.method===s)&&e.scope===r&&compareArray(e.mods,n))}))})};function eventHandler(e,n,t,o){var r;if(n.element===o&&(n.scope===t||"all"===n.scope)){for(var s in r=0<n.mods.length,_mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(!_mods[s]&&~n.mods.indexOf(+s)||_mods[s]&&!~n.mods.indexOf(+s))&&(r=!1);(0!==n.mods.length||_mods[16]||_mods[18]||_mods[17]||_mods[91])&&!r&&"*"!==n.shortcut||(n.keys=[],n.keys=n.keys.concat(_downKeys),!1===n.method(e,n)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble)&&(e.cancelBubble=!0))}}function dispatch(t,e){var n=_handlers["*"],o=t.keyCode||t.which||t.charCode;if(hotkeys.filter.call(this,t)){if(~_downKeys.indexOf(o=93!==o&&224!==o?o:91)||229===o||_downKeys.push(o),["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)))}),o in _mods){for(var r in _mods[o]=!0,_modifier)_modifier[r]===o&&(hotkeys[r]=!0);if(!n)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(n)for(var d=0;d<n.length;d++)n[d].scope===i&&("keydown"===t.type&&n[d].keydown||"keyup"===t.type&&n[d].keyup)&&eventHandler(t,n[d],i,e);if(o in _handlers)for(var a=0;a<_handlers[o].length;a++)if(("keydown"===t.type&&_handlers[o][a].keydown||"keyup"===t.type&&_handlers[o][a].keyup)&&_handlers[o][a].key){for(var c=_handlers[o][a],f=c.key.split(c.splitKey),l=[],y=0;y<f.length;y++)l.push(code(f[y]));l.sort().join("")===_downKeys.sort().join("")&&eventHandler(t,c,i,e)}}}function isElementBind(e){return!!~elementHasBindEvent.indexOf(e)}function hotkeys(e,n,t){_downKeys=[];var o=getKeys(e),r=[],s="all",i=document,d=0,a=!1,c=!0,f="+",l=!1;for(void 0===t&&"function"==typeof n&&(t=n),"[object Object]"===Object.prototype.toString.call(n)&&(n.scope&&(s=n.scope),n.element&&(i=n.element),n.keyup&&(a=n.keyup),void 0!==n.keydown&&(c=n.keydown),void 0!==n.capture&&(l=n.capture),"string"==typeof n.splitKey)&&(f=n.splitKey),"string"==typeof n&&(s=n);d<o.length;d++)r=[],1<(e=o[d].split(f)).length&&(r=getMods(_modifier,e)),(e="*"===(e=e[e.length-1])?"*":code(e))in _handlers||(_handlers[e]=[]),_handlers[e].push({keyup:a,keydown:c,scope:s,mods:r,shortcut:o[d],method:t,key:o[d],splitKey:f,element:i});void 0!==i&&!isElementBind(i)&&window&&(elementHasBindEvent.push(i),addEvent(i,"keydown",function(e){dispatch(e,i)},l),winListendFocus||(winListendFocus=!0,addEvent(window,"focus",function(){_downKeys=[]},l)),addEvent(i,"keyup",function(e){dispatch(e,i),clearModifier(e)},l))}function trigger(n){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(_handlers).forEach(function(e){_handlers[e].filter(function(e){return e.scope===t&&e.shortcut===n}).forEach(function(e){e&&e.method&&e.method()})})}var a,_hotkeys,_api={getPressedKeyString:getPressedKeyString,setScope:setScope,getScope:getScope,deleteScope:deleteScope,getPressedKeyCodes:getPressedKeyCodes,getAllKeyCodes:getAllKeyCodes,isPressed:isPressed,filter:filter,trigger:trigger,unbind:unbind,keyMap:_keyMap,modifier:_modifier,modifierMap:modifierMap};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.11.2
* hotkeys-js v3.12.0
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.

@@ -190,2 +190,22 @@ *

}
function getAllKeyCodes() {
var result = [];
Object.keys(_handlers).forEach(function (k) {
_handlers[k].forEach(function (_ref) {
var key = _ref.key,
scope = _ref.scope,
mods = _ref.mods,
shortcut = _ref.shortcut;
result.push({
scope: scope,
shortcut: shortcut,
mods: mods,
keys: key.split('+').map(function (v) {
return code(v);
})
});
});
});
return result;
}

@@ -293,8 +313,8 @@ // 表单控件控件判断 返回 Boolean

// 解除绑定某个范围的快捷键
var eachUnbind = function eachUnbind(_ref) {
var key = _ref.key,
scope = _ref.scope,
method = _ref.method,
_ref$splitKey = _ref.splitKey,
splitKey = _ref$splitKey === void 0 ? '+' : _ref$splitKey;
var eachUnbind = function eachUnbind(_ref2) {
var key = _ref2.key,
scope = _ref2.scope,
method = _ref2.method,
_ref2$splitKey = _ref2.splitKey,
splitKey = _ref2$splitKey === void 0 ? '+' : _ref2$splitKey;
var multipleKeys = getKeys(key);

@@ -551,2 +571,3 @@ multipleKeys.forEach(function (originKey) {

getPressedKeyCodes: getPressedKeyCodes,
getAllKeyCodes: getAllKeyCodes,
isPressed: isPressed,

@@ -553,0 +574,0 @@ filter: filter,

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

@@ -196,2 +196,22 @@ *

}
function getAllKeyCodes() {
var result = [];
Object.keys(_handlers).forEach(function (k) {
_handlers[k].forEach(function (_ref) {
var key = _ref.key,
scope = _ref.scope,
mods = _ref.mods,
shortcut = _ref.shortcut;
result.push({
scope: scope,
shortcut: shortcut,
mods: mods,
keys: key.split('+').map(function (v) {
return code(v);
})
});
});
});
return result;
}

@@ -299,8 +319,8 @@ // 表单控件控件判断 返回 Boolean

// 解除绑定某个范围的快捷键
var eachUnbind = function eachUnbind(_ref) {
var key = _ref.key,
scope = _ref.scope,
method = _ref.method,
_ref$splitKey = _ref.splitKey,
splitKey = _ref$splitKey === void 0 ? '+' : _ref$splitKey;
var eachUnbind = function eachUnbind(_ref2) {
var key = _ref2.key,
scope = _ref2.scope,
method = _ref2.method,
_ref2$splitKey = _ref2.splitKey,
splitKey = _ref2$splitKey === void 0 ? '+' : _ref2$splitKey;
var multipleKeys = getKeys(key);

@@ -557,2 +577,3 @@ multipleKeys.forEach(function (originKey) {

getPressedKeyCodes: getPressedKeyCodes,
getAllKeyCodes: getAllKeyCodes,
isPressed: isPressed,

@@ -559,0 +580,0 @@ filter: filter,

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

/*! hotkeys-js v3.11.2 | MIT © 2023 kenny wong <wowohoo@qq.com> https://jaywcjlove.github.io/hotkeys-js */
!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 d(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):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 y(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 o={backspace:8,"\u232b":8,tab:9,clear:12,enter:13,"\u21a9":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},h={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,command:91},m={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},g={16:!1,18:!1,17:!1,91:!1},v={},t=1;t<20;t++)o["f".concat(t)]=111+t;var k=[],w=!1,n="all",O=[],K=function(e){return o[e.toLowerCase()]||h[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function i(e){n=e||"all"}function b(){return n||"all"}function f(e){var r=e.scope,i=e.method,t=e.splitKey,f=void 0===t?"+":t;y(e.key).forEach(function(e){var t,e=e.split(f),n=e.length,o=e[n-1],o="*"===o?"*":K(o);v[o]&&(r=r||b(),t=1<n?p(h,e):[],v[o]=v[o].filter(function(e){return!((!i||e.method===i)&&e.scope===r&&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,t))}))})}function x(e,t,n,o){var r;if(t.element===o&&(t.scope===n||"all"===t.scope)){for(var i in r=0<t.mods.length,g)Object.prototype.hasOwnProperty.call(g,i)&&(!g[i]&&~t.mods.indexOf(+i)||g[i]&&!~t.mods.indexOf(+i))&&(r=!1);(0!==t.mods.length||g[16]||g[18]||g[17]||g[91])&&!r&&"*"!==t.shortcut||(t.keys=[],t.keys=t.keys.concat(k),!1===t.method(e,t)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function C(n,e){var t=v["*"],o=n.keyCode||n.which||n.charCode;if(E.filter.call(this,n)){if(~k.indexOf(o=93!==o&&224!==o?o:91)||229===o||k.push(o),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var t=m[e];n[e]&&!~k.indexOf(t)?k.push(t):!n[e]&&~k.indexOf(t)?k.splice(k.indexOf(t),1):"metaKey"!==e||!n[e]||3!==k.length||n.ctrlKey||n.shiftKey||n.altKey||(k=k.slice(k.indexOf(t)))}),o in g){for(var r in g[o]=!0,h)h[r]===o&&(E[r]=!0);if(!t)return}for(var i in g)Object.prototype.hasOwnProperty.call(g,i)&&(g[i]=n[m[i]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~k.indexOf(17)||k.push(17),~k.indexOf(18)||k.push(18),g[17]=!0,g[18]=!0);var f=b();if(t)for(var c=0;c<t.length;c++)t[c].scope===f&&("keydown"===n.type&&t[c].keydown||"keyup"===n.type&&t[c].keyup)&&x(n,t[c],f,e);if(o in v)for(var a=0;a<v[o].length;a++)if(("keydown"===n.type&&v[o][a].keydown||"keyup"===n.type&&v[o][a].keyup)&&v[o][a].key){for(var l=v[o][a],s=l.key.split(l.splitKey),u=[],d=0;d<s.length;d++)u.push(K(s[d]));u.sort().join("")===k.sort().join("")&&x(n,l,f,e)}}}function E(e,t,n){k=[];var o=y(e),r=[],i="all",f=document,c=0,a=!1,l=!0,s="+",u=!1;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&&(a=t.keyup),void 0!==t.keydown&&(l=t.keydown),void 0!==t.capture&&(u=t.capture),"string"==typeof t.splitKey&&(s=t.splitKey)),"string"==typeof t&&(i=t);c<o.length;c++)r=[],1<(e=o[c].split(s)).length&&(r=p(h,e)),(e="*"===(e=e[e.length-1])?"*":K(e))in v||(v[e]=[]),v[e].push({keyup:a,keydown:l,scope:i,mods:r,shortcut:o[c],method:n,key:o[c],splitKey:s,element:f});void 0!==f&&(t=f,!~O.indexOf(t))&&window&&(O.push(f),d(f,"keydown",function(e){C(e,f)},u),w||(w=!0,d(window,"focus",function(){k=[]},u)),d(f,"keyup",function(e){C(e,f);var t=e.keyCode||e.which||e.charCode,n=k.indexOf(t);if(n<0||k.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&k.splice(0,k.length),(t=93!==t&&224!==t?t:91)in g)for(var o in g[t]=!1,h)h[o]===t&&(E[o]=!1)},u))}var r,c,a={getPressedKeyString:function(){return k.map(function(e){return n=e,Object.keys(o).find(function(e){return o[e]===n})||(t=e,Object.keys(h).find(function(e){return h[e]===t}))||String.fromCharCode(e);var t,n})},setScope:i,getScope:b,deleteScope:function(e,t){var n,o,r;for(r in e=e||b(),v)if(Object.prototype.hasOwnProperty.call(v,r))for(n=v[r],o=0;o<n.length;)n[o].scope===e?n.splice(o,1):o++;b()===e&&i(t||"all")},getPressedKeyCodes:function(){return k.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=K(e)),!!~k.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},trigger:function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(v).forEach(function(e){v[e].filter(function(e){return e.scope===n&&e.shortcut===t}).forEach(function(e){e&&e.method&&e.method()})})},unbind:function(e){if(void 0===e)Object.keys(v).forEach(function(e){return delete v[e]});else 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:"+"})}},keyMap:o,modifier:h,modifierMap:m};for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(E[r]=a[r]);return"undefined"!=typeof window&&(c=window.hotkeys,E.noConflict=function(e){return e&&window.hotkeys===E&&(window.hotkeys=c),E},window.hotkeys=E),E});
/*! hotkeys-js v3.12.0 | MIT © 2023 kenny wong <wowohoo@qq.com> https://jaywcjlove.github.io/hotkeys-js */
!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 p(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):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){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 o={backspace:8,"\u232b":8,tab:9,clear:12,enter:13,"\u21a9":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},h={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,command:91},m={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},g={16:!1,18:!1,17:!1,91:!1},v={},t=1;t<20;t++)o["f".concat(t)]=111+t;var k=[],w=!1,n="all",O=[],K=function(e){return o[e.toLowerCase()]||h[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function i(e){n=e||"all"}function b(){return n||"all"}function c(e){var r=e.scope,i=e.method,t=e.splitKey,c=void 0===t?"+":t;y(e.key).forEach(function(e){var t,e=e.split(c),n=e.length,o=e[n-1],o="*"===o?"*":K(o);v[o]&&(r=r||b(),t=1<n?d(h,e):[],v[o]=v[o].filter(function(e){return!((!i||e.method===i)&&e.scope===r&&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,t))}))})}function x(e,t,n,o){var r;if(t.element===o&&(t.scope===n||"all"===t.scope)){for(var i in r=0<t.mods.length,g)Object.prototype.hasOwnProperty.call(g,i)&&(!g[i]&&~t.mods.indexOf(+i)||g[i]&&!~t.mods.indexOf(+i))&&(r=!1);(0!==t.mods.length||g[16]||g[18]||g[17]||g[91])&&!r&&"*"!==t.shortcut||(t.keys=[],t.keys=t.keys.concat(k),!1===t.method(e,t)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble)&&(e.cancelBubble=!0))}}function C(n,e){var t=v["*"],o=n.keyCode||n.which||n.charCode;if(E.filter.call(this,n)){if(~k.indexOf(o=93!==o&&224!==o?o:91)||229===o||k.push(o),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(e){var t=m[e];n[e]&&!~k.indexOf(t)?k.push(t):!n[e]&&~k.indexOf(t)?k.splice(k.indexOf(t),1):"metaKey"!==e||!n[e]||3!==k.length||n.ctrlKey||n.shiftKey||n.altKey||(k=k.slice(k.indexOf(t)))}),o in g){for(var r in g[o]=!0,h)h[r]===o&&(E[r]=!0);if(!t)return}for(var i in g)Object.prototype.hasOwnProperty.call(g,i)&&(g[i]=n[m[i]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~k.indexOf(17)||k.push(17),~k.indexOf(18)||k.push(18),g[17]=!0,g[18]=!0);var c=b();if(t)for(var f=0;f<t.length;f++)t[f].scope===c&&("keydown"===n.type&&t[f].keydown||"keyup"===n.type&&t[f].keyup)&&x(n,t[f],c,e);if(o in v)for(var a=0;a<v[o].length;a++)if(("keydown"===n.type&&v[o][a].keydown||"keyup"===n.type&&v[o][a].keyup)&&v[o][a].key){for(var s=v[o][a],l=s.key.split(s.splitKey),u=[],p=0;p<l.length;p++)u.push(K(l[p]));u.sort().join("")===k.sort().join("")&&x(n,s,c,e)}}}function E(e,t,n){k=[];var o=y(e),r=[],i="all",c=document,f=0,a=!1,s=!0,l="+",u=!1;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(i=t.scope),t.element&&(c=t.element),t.keyup&&(a=t.keyup),void 0!==t.keydown&&(s=t.keydown),void 0!==t.capture&&(u=t.capture),"string"==typeof t.splitKey)&&(l=t.splitKey),"string"==typeof t&&(i=t);f<o.length;f++)r=[],1<(e=o[f].split(l)).length&&(r=d(h,e)),(e="*"===(e=e[e.length-1])?"*":K(e))in v||(v[e]=[]),v[e].push({keyup:a,keydown:s,scope:i,mods:r,shortcut:o[f],method:n,key:o[f],splitKey:l,element:c});void 0!==c&&(t=c,!~O.indexOf(t))&&window&&(O.push(c),p(c,"keydown",function(e){C(e,c)},u),w||(w=!0,p(window,"focus",function(){k=[]},u)),p(c,"keyup",function(e){C(e,c);var t=e.keyCode||e.which||e.charCode,n=k.indexOf(t);if(n<0||k.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&k.splice(0,k.length),(t=93!==t&&224!==t?t:91)in g)for(var o in g[t]=!1,h)h[o]===t&&(E[o]=!1)},u))}var r,f,a={getPressedKeyString:function(){return k.map(function(e){return n=e,Object.keys(o).find(function(e){return o[e]===n})||(t=e,Object.keys(h).find(function(e){return h[e]===t}))||String.fromCharCode(e);var t,n})},setScope:i,getScope:b,deleteScope:function(e,t){var n,o,r;for(r in e=e||b(),v)if(Object.prototype.hasOwnProperty.call(v,r))for(n=v[r],o=0;o<n.length;)n[o].scope===e?n.splice(o,1):o++;b()===e&&i(t||"all")},getPressedKeyCodes:function(){return k.slice(0)},getAllKeyCodes:function(){var n=[];return Object.keys(v).forEach(function(e){v[e].forEach(function(e){var t=e.key;n.push({scope:e.scope,shortcut:e.shortcut,mods:e.mods,keys:t.split("+").map(function(e){return K(e)})})})}),n},isPressed:function(e){return"string"==typeof e&&(e=K(e)),!!~k.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},trigger:function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(v).forEach(function(e){v[e].filter(function(e){return e.scope===n&&e.shortcut===t}).forEach(function(e){e&&e.method&&e.method()})})},unbind:function(e){if(void 0===e)Object.keys(v).forEach(function(e){return delete v[e]});else if(Array.isArray(e))e.forEach(function(e){e.key&&c(e)});else if("object"==typeof e)e.key&&c(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=""),c({key:e,scope:r,method:i,splitKey:"+"})}},keyMap:o,modifier:h,modifierMap:m};for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(E[r]=a[r]);return"undefined"!=typeof window&&(f=window.hotkeys,E.noConflict=function(e){return e&&window.hotkeys===E&&(window.hotkeys=f),E},window.hotkeys=E),E});

@@ -40,8 +40,67 @@ export interface HotkeysEvent {

/**
* Use the `hotkeys.setScope` method to set scope. There can only be one active scope besides 'all'. By default 'all' is always active.
*
* ```js
* // Define shortcuts with a scope
* hotkeys('ctrl+o, ctrl+alt+enter', 'issues', function() {
* console.log('do something');
* });
* hotkeys('o, enter', 'files', function() {
* console.log('do something else');
* });
*
* // Set the scope (only 'all' and 'issues' shortcuts will be honored)
* hotkeys.setScope('issues'); // default scope is 'all'
* ```
*/
setScope(scopeName: string): void;
/**
* Use the `hotkeys.getScope` method to get scope.
*
* ```js
* hotkeys.getScope();
* ```
*/
getScope(): string;
/**
* Use the `hotkeys.deleteScope` method to delete a scope. This will also remove all associated hotkeys with it.
*
* ```js
* hotkeys.deleteScope('issues');
* ```
* You can use second argument, if need set new scope after deleting.
*
* ```js
* hotkeys.deleteScope('issues', 'newScopeName');
* ```
*/
deleteScope(scopeName: string, newScopeName?: string): void;
/**
* Relinquish HotKeys’s control of the `hotkeys` variable.
*
* ```js
* var k = hotkeys.noConflict();
* k('a', function() {
* console.log("do something")
* });
*
* hotkeys()
* // -->Uncaught TypeError: hotkeys is not a function(anonymous function)
* // @ VM2170:2InjectedScript._evaluateOn
* // @ VM2165:883InjectedScript._evaluateAndWrap
* // @ VM2165:816InjectedScript.evaluate @ VM2165:682
* ```
*/
noConflict(): Hotkeys;
/**
* trigger shortcut key event
*
* ```js
* hotkeys.trigger('ctrl+o');
* hotkeys.trigger('ctrl+o', 'scope2');
* ```
*/
trigger(shortcut: string, scope?: string): void;

@@ -54,7 +113,66 @@

/** For example, `hotkeys.isPressed(77)` is true if the `M` key is currently pressed. */
isPressed(keyCode: number): boolean;
/** For example, `hotkeys.isPressed('m')` is true if the `M` key is currently pressed. */
isPressed(keyCode: string): boolean;
/**
* Returns an array of key codes currently pressed.
*
* ```js
* hotkeys('command+ctrl+shift+a,f', function() {
* console.log(hotkeys.getPressedKeyCodes()); //=> [17, 65] or [70]
* })
* ```
*/
getPressedKeyCodes(): number[];
/**
* Returns an array of key codes currently pressed.
*
* ```js
* hotkeys('command+ctrl+shift+a,f', function() {
* console.log(hotkeys.getPressedKeyString()); //=> ['⌘', '⌃', '⇧', 'A', 'F']
* })
* ```
*/
getPressedKeyString(): string[];
/**
* Get a list of all registration codes.
*
* ```js
* hotkeys('command+ctrl+shift+a,f', function() {
* console.log(hotkeys.getAllKeyCodes());
* // [
* // { scope: 'all', shortcut: 'command+ctrl+shift+a', mods: [91, 17, 16], keys: [91, 17, 16, 65] },
* // { scope: 'all', shortcut: 'f', mods: [], keys: [42] }
* // ]
* })
* ```
*
*/
getAllKeyCodes(): Omit<HotkeysEvent, 'method' | 'key'>;
/**
* By default hotkeys are not enabled for `INPUT` `SELECT` `TEXTAREA` elements.
* `Hotkeys.filter` to return to the `true` shortcut keys set to play a role,
* `false` shortcut keys set up failure.
*
* ```js
* hotkeys.filter = function(event){
* return true;
* }
* //How to add the filter to edit labels. <div contentEditable="true"></div>
* //"contentEditable" Older browsers that do not support drops
* hotkeys.filter = function(event) {
* var target = event.target || event.srcElement;
* var tagName = target.tagName;
* return !(target.isContentEditable || tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
* }
*
* hotkeys.filter = function(event){
* var tagName = (event.target || event.srcElement).tagName;
* hotkeys.setScope(/^(INPUT|TEXTAREA|SELECT)$/.test(tagName) ? 'input' : 'other');
* return true;
* }
* ```
*/
filter(event: KeyboardEvent): boolean;

@@ -61,0 +179,0 @@ }

{
"name": "hotkeys-js",
"description": "A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.",
"version": "3.11.2",
"version": "3.12.0",
"main": "index.js",
"types": "index.d.ts",
"module": "dist/hotkeys.esm.js",
"scripts": {
"prepare": "npm run build:lib && husky install",
"lint": "eslint --ignore-pattern dist --ext .js src website",
"build:lib": "node scripts/build.js",
"build": "npm run build:lib && npm run doc && npm run lint",
"watch": "node scripts/watch.js",
"pretest": "npm run build",
"test": "jest --coverage --detectOpenHandles",
"test:watch": "jest --watch",
"doc": "kkt build --app-src ./website",
"start": "kkt start --app-src ./website"
},
"files": [

@@ -42,54 +30,3 @@ "index.d.ts",

"url": "https://github.com/jaywcjlove/hotkeys.git"
},
"jest": {
"testURL": "http://localhost/"
},
"devDependencies": {
"@babel/eslint-parser": "^7.18.9",
"@kkt/less-modules": "^7.2.0",
"@kkt/raw-modules": "^7.2.0",
"@kkt/scope-plugin-options": "^7.2.0",
"@rollup/plugin-babel": "~5.3.1",
"@rollup/plugin-commonjs": "~22.0.2",
"@rollup/plugin-node-resolve": "~13.3.0",
"@uiw/react-github-corners": "~1.5.14",
"@uiw/react-mac-keyboard": "~1.1.4",
"@uiw/react-markdown-preview": "~4.0.24",
"@uiw/react-shields": "~1.1.3",
"@wcj/dark-mode": "~1.0.15",
"bannerjs": "~2.1.0",
"classnames": "~2.3.1",
"colors-cli": "~1.0.28",
"eslint": "~8.22.0",
"eslint-config-airbnb": "~19.0.4",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-jsx-a11y": "~6.6.1",
"eslint-plugin-react": "~7.30.1",
"husky": "~8.0.1",
"jest": "~27.5.1",
"kkt": "^7.2.0",
"lint-staged": "~13.0.3",
"puppeteer": "~13.5.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"rimraf": "~3.0.2",
"rollup": "~2.78.1",
"uglify-js": "~3.17.0",
"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"
]
},
"lint-staged": {
"src/**/*.js": "eslint --ext .js src website"
}
}
}

@@ -167,3 +167,3 @@ # Hotkeys

element: document.getElementById('wrapper'),
}, function(){
}, function() {
console.log('do something else');

@@ -241,6 +241,6 @@ });

// Define shortcuts with a scope
hotkeys('ctrl+o, ctrl+alt+enter', 'issues', function(){
hotkeys('ctrl+o, ctrl+alt+enter', 'issues', function() {
console.log('do something');
});
hotkeys('o, enter', 'files', function(){
hotkeys('o, enter', 'files', function() {
console.log('do something else');

@@ -320,2 +320,4 @@ });

trigger shortcut key event
```js

@@ -331,3 +333,3 @@ hotkeys.trigger('ctrl+o');

```js
hotkeys('command+ctrl+shift+a,f', function(){
hotkeys('command+ctrl+shift+a,f', function() {
console.log(hotkeys.getPressedKeyCodes()); //=> [17, 65] or [70]

@@ -337,9 +339,8 @@ })

### getPressedKeyString
### getPressedKeyStrings
Returns an array of key codes currently pressed.
```js
hotkeys('command+ctrl+shift+a,f', function(){
hotkeys('command+ctrl+shift+a,f', function() {
console.log(hotkeys.getPressedKeyString()); //=> ['⌘', '⌃', '⇧', 'A', 'F']

@@ -349,2 +350,16 @@ })

### getAllKeyCodes
Get a list of all registration codes.
```js
hotkeys('command+ctrl+shift+a,f', function() {
console.log(hotkeys.getAllKeyCodes());
// [
// { scope: 'all', shortcut: 'command+ctrl+shift+a', mods: [91, 17, 16], keys: [91, 17, 16, 65] },
// { scope: 'all', shortcut: 'f', mods: [], keys: [42] }
// ]
})
```
### filter

@@ -351,0 +366,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