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.13.5 to 3.13.6

5

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

@@ -217,4 +217,5 @@ *

let flag = true;
const isInput = tagName === 'INPUT' && !['checkbox', 'radio', 'range', 'button', 'file', 'reset', 'submit', 'color'].includes(target.type);
// ignore: isContentEditable === 'true', <input> and <textarea> when readOnly state is false, <select>
if (target.isContentEditable || (tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT') && !target.readOnly) {
if (target.isContentEditable || (isInput || tagName === 'TEXTAREA' || tagName === 'SELECT') && !target.readOnly) {
flag = false;

@@ -221,0 +222,0 @@ }

4

dist/hotkeys.common.min.js

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

/*! hotkeys-js v3.13.5 | MIT © 2024 kenny wong <wowohoo@qq.com> https://jaywcjlove.github.io/hotkeys-js */
"use strict";const isff="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function addEvent(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent&&e.attachEvent("on".concat(t),n)}function removeEvent(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.deachEvent&&e.deachEvent("on".concat(t),n)}function getMods(t,e){var n=e.slice(0,e.length-1);for(let e=0;e<n.length;e++)n[e]=t[n[e].toLowerCase()];return n}function getKeys(e){var t=(e=(e="string"!=typeof e?"":e).replace(/\s/g,"")).split(",");let n=t.lastIndexOf("");for(;0<=n;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function compareArray(e,t){var n=e.length<t.length?t:e,o=e.length<t.length?e:t;let s=!0;for(let e=0;e<n.length;e++)~o.indexOf(n[e])||(s=!1);return s}const _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={};for(let e=1;e<20;e++)_keyMap["f".concat(e)]=111+e;let _downKeys=[],winListendFocus=null,_scope="all";const elementEventMap=new Map,code=e=>_keyMap[e.toLowerCase()]||_modifier[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),getKey=t=>Object.keys(_keyMap).find(e=>_keyMap[e]===t),getModifier=t=>Object.keys(_modifier).find(e=>_modifier[e]===t);function setScope(e){_scope=e||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function getPressedKeyString(){return _downKeys.map(e=>getKey(e)||getModifier(e)||String.fromCharCode(e))}function getAllKeyCodes(){const s=[];return Object.keys(_handlers).forEach(e=>{_handlers[e].forEach(e=>{var{key:e,scope:t,mods:n,shortcut:o}=e;s.push({scope:t,shortcut:o,mods:n,keys:e.split("+").map(e=>code(e))})})}),s}function filter(e){var e=e.target||e.srcElement,t=e["tagName"];let n=!e.isContentEditable&&("INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t||e.readOnly)?!0:!1;return n}function isPressed(e){return"string"==typeof e&&(e=code(e)),!!~_downKeys.indexOf(e)}function deleteScope(e,t){var n;let o;e=e||getScope();for(const s in _handlers)if(Object.prototype.hasOwnProperty.call(_handlers,s))for(n=_handlers[s],o=0;o<n.length;)n[o].scope===e?n.splice(o,1).forEach(e=>{e=e.element;return removeKeyEvent(e)}):o++;getScope()===e&&setScope(t||"all")}function clearModifier(e){let t=e.keyCode||e.which||e.charCode;var n=_downKeys.indexOf(t);if(n<0||_downKeys.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&_downKeys.splice(0,_downKeys.length),(t=93!==t&&224!==t?t:91)in _mods){_mods[t]=!1;for(const o in _modifier)_modifier[o]===t&&(hotkeys[o]=!1)}}function unbind(n){if(void 0===n)Object.keys(_handlers).forEach(e=>{Array.isArray(_handlers[e])&&_handlers[e].forEach(e=>eachUnbind(e)),delete _handlers[e]}),removeKeyEvent(null);else if(Array.isArray(n))n.forEach(e=>{e.key&&eachUnbind(e)});else if("object"==typeof n)n.key&&eachUnbind(n);else if("string"==typeof n){for(var o=arguments.length,s=Array(1<o?o-1:0),r=1;r<o;r++)s[r-1]=arguments[r];let[e,t]=s;"function"==typeof e&&(t=e,e=""),eachUnbind({key:n,scope:e,method:t,splitKey:"+"})}}const eachUnbind=e=>{let{key:t,scope:r,method:d,splitKey:i="+"}=e;getKeys(t).forEach(e=>{var e=e.split(i),t=e.length,n=e[t-1],n="*"===n?"*":code(n);if(_handlers[n]){r=r||getScope();const o=1<t?getMods(_modifier,e):[],s=[];_handlers[n]=_handlers[n].filter(e=>{var t=(!d||e.method===d)&&e.scope===r&&compareArray(e.mods,o);return t&&s.push(e.element),!t}),s.forEach(e=>removeKeyEvent(e))}})};function eventHandler(t,n,o,e){if(n.element===e){let e;if(n.scope===o||"all"===n.scope){e=0<n.mods.length;for(const s in _mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(!_mods[s]&&~n.mods.indexOf(+s)||_mods[s]&&!~n.mods.indexOf(+s))&&(e=!1);(0!==n.mods.length||_mods[16]||_mods[18]||_mods[17]||_mods[91])&&!e&&"*"!==n.shortcut||(n.keys=[],n.keys=n.keys.concat(_downKeys),!1===n.method(t,n)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble)&&(t.cancelBubble=!0))}}}function dispatch(n,t){var o=_handlers["*"];let e=n.keyCode||n.which||n.charCode;if(hotkeys.filter.call(this,n)){if(93!==e&&224!==e||(e=91),~_downKeys.indexOf(e)||229===e||_downKeys.push(e),["ctrlKey","altKey","shiftKey","metaKey"].forEach(e=>{var t=modifierMap[e];n[e]&&!~_downKeys.indexOf(t)?_downKeys.push(t):!n[e]&&~_downKeys.indexOf(t)?_downKeys.splice(_downKeys.indexOf(t),1):"metaKey"!==e||!n[e]||3!==_downKeys.length||n.ctrlKey||n.shiftKey||n.altKey||(_downKeys=_downKeys.slice(_downKeys.indexOf(t)))}),e in _mods){_mods[e]=!0;for(const y in _modifier)_modifier[y]===e&&(hotkeys[y]=!0);if(!o)return}for(const p in _mods)Object.prototype.hasOwnProperty.call(_mods,p)&&(_mods[p]=n[modifierMap[p]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~_downKeys.indexOf(17)||_downKeys.push(17),~_downKeys.indexOf(18)||_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);var s=getScope();if(o)for(let e=0;e<o.length;e++)o[e].scope===s&&("keydown"===n.type&&o[e].keydown||"keyup"===n.type&&o[e].keyup)&&eventHandler(n,o[e],s,t);if(e in _handlers){var r=_handlers[e],d=r.length;for(let e=0;e<d;e++)if(("keydown"===n.type&&r[e].keydown||"keyup"===n.type&&r[e].keyup)&&r[e].key){var i=r[e],a=i["splitKey"],l=i.key.split(a),c=[];for(let e=0;e<l.length;e++)c.push(code(l[e]));c.sort().join("")===_downKeys.sort().join("")&&eventHandler(n,i,s,t)}}}}function hotkeys(e,t,n){_downKeys=[];var o,s=getKeys(e);let r=[],d="all",i=document,a=0,l=!1,c=!0,y="+",p=!1,f=!1;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(d=t.scope),t.element&&(i=t.element),t.keyup&&(l=t.keyup),void 0!==t.keydown&&(c=t.keydown),void 0!==t.capture&&(p=t.capture),"string"==typeof t.splitKey&&(y=t.splitKey),!0===t.single)&&(f=!0),"string"==typeof t&&(d=t),f&&unbind(e,d);a<s.length;a++)e=s[a].split(y),r=[],1<e.length&&(r=getMods(_modifier,e)),(e="*"===(e=e[e.length-1])?"*":code(e))in _handlers||(_handlers[e]=[]),_handlers[e].push({keyup:l,keydown:c,scope:d,mods:r,shortcut:s[a],method:n,key:s[a],splitKey:y,element:i});void 0!==i&&window&&(elementEventMap.has(i)||(t=function(){return dispatch(0<arguments.length&&void 0!==arguments[0]?arguments[0]:window.event,i)},o=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:window.event;dispatch(e,i),clearModifier(e)},elementEventMap.set(i,{keydownListener:t,keyupListenr:o,capture:p}),addEvent(i,"keydown",t,p),addEvent(i,"keyup",o,p)),winListendFocus||(t=()=>{_downKeys=[]},winListendFocus={listener:t,capture:p},addEvent(window,"focus",t,p)))}function trigger(t){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(_handlers).forEach(e=>{_handlers[e].filter(e=>e.scope===n&&e.shortcut===t).forEach(e=>{e&&e.method&&e.method()})})}function removeKeyEvent(t){var e,n,o,s=Object.values(_handlers).flat();s.findIndex(e=>{e=e.element;return e===t})<0&&({keydownListener:o,keyupListenr:n,capture:e}=elementEventMap.get(t)||{},o)&&n&&(removeEvent(t,"keyup",n,e),removeEvent(t,"keydown",o,e),elementEventMap.delete(t)),0<s.length&&0<elementEventMap.size||(Object.keys(elementEventMap).forEach(e=>{var{keydownListener:t,keyupListenr:n,capture:o}=elementEventMap.get(e)||{};t&&n&&(removeEvent(e,"keyup",n,o),removeEvent(e,"keydown",t,o),elementEventMap.delete(e))}),elementEventMap.clear(),Object.keys(_handlers).forEach(e=>delete _handlers[e]),winListendFocus&&({listener:n,capture:o}=winListendFocus,removeEvent(window,"focus",n,o),winListendFocus=null))}const _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(const K0 in _api)Object.prototype.hasOwnProperty.call(_api,K0)&&(hotkeys[K0]=_api[K0]);if("undefined"!=typeof window){const L0=window.hotkeys;hotkeys.noConflict=e=>(e&&window.hotkeys===hotkeys&&(window.hotkeys=L0),hotkeys),window.hotkeys=hotkeys}module.exports=hotkeys;
/*! hotkeys-js v3.13.6 | MIT © 2024 kenny wong <wowohoo@qq.com> https://jaywcjlove.github.io/hotkeys-js */
"use strict";const isff="undefined"!=typeof navigator&&0<navigator.userAgent.toLowerCase().indexOf("firefox");function addEvent(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent&&e.attachEvent("on".concat(t),n)}function removeEvent(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.deachEvent&&e.deachEvent("on".concat(t),n)}function getMods(t,e){var n=e.slice(0,e.length-1);for(let e=0;e<n.length;e++)n[e]=t[n[e].toLowerCase()];return n}function getKeys(e){var t=(e=(e="string"!=typeof e?"":e).replace(/\s/g,"")).split(",");let n=t.lastIndexOf("");for(;0<=n;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function compareArray(e,t){var n=e.length<t.length?t:e,o=e.length<t.length?e:t;let s=!0;for(let e=0;e<n.length;e++)~o.indexOf(n[e])||(s=!1);return s}const _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={};for(let e=1;e<20;e++)_keyMap["f".concat(e)]=111+e;let _downKeys=[],winListendFocus=null,_scope="all";const elementEventMap=new Map,code=e=>_keyMap[e.toLowerCase()]||_modifier[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),getKey=t=>Object.keys(_keyMap).find(e=>_keyMap[e]===t),getModifier=t=>Object.keys(_modifier).find(e=>_modifier[e]===t);function setScope(e){_scope=e||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function getPressedKeyString(){return _downKeys.map(e=>getKey(e)||getModifier(e)||String.fromCharCode(e))}function getAllKeyCodes(){const s=[];return Object.keys(_handlers).forEach(e=>{_handlers[e].forEach(e=>{var{key:e,scope:t,mods:n,shortcut:o}=e;s.push({scope:t,shortcut:o,mods:n,keys:e.split("+").map(e=>code(e))})})}),s}function filter(e){var e=e.target||e.srcElement,t=e["tagName"];let n=!0;var o="INPUT"===t&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(e.type);return n=!e.isContentEditable&&(!o&&"TEXTAREA"!==t&&"SELECT"!==t||e.readOnly)?n:!1}function isPressed(e){return"string"==typeof e&&(e=code(e)),!!~_downKeys.indexOf(e)}function deleteScope(e,t){var n;let o;e=e||getScope();for(const s in _handlers)if(Object.prototype.hasOwnProperty.call(_handlers,s))for(n=_handlers[s],o=0;o<n.length;)n[o].scope===e?n.splice(o,1).forEach(e=>{e=e.element;return removeKeyEvent(e)}):o++;getScope()===e&&setScope(t||"all")}function clearModifier(e){let t=e.keyCode||e.which||e.charCode;var n=_downKeys.indexOf(t);if(n<0||_downKeys.splice(n,1),e.key&&"meta"==e.key.toLowerCase()&&_downKeys.splice(0,_downKeys.length),(t=93!==t&&224!==t?t:91)in _mods){_mods[t]=!1;for(const o in _modifier)_modifier[o]===t&&(hotkeys[o]=!1)}}function unbind(n){if(void 0===n)Object.keys(_handlers).forEach(e=>{Array.isArray(_handlers[e])&&_handlers[e].forEach(e=>eachUnbind(e)),delete _handlers[e]}),removeKeyEvent(null);else if(Array.isArray(n))n.forEach(e=>{e.key&&eachUnbind(e)});else if("object"==typeof n)n.key&&eachUnbind(n);else if("string"==typeof n){for(var o=arguments.length,s=Array(1<o?o-1:0),r=1;r<o;r++)s[r-1]=arguments[r];let[e,t]=s;"function"==typeof e&&(t=e,e=""),eachUnbind({key:n,scope:e,method:t,splitKey:"+"})}}const eachUnbind=e=>{let{key:t,scope:r,method:i,splitKey:d="+"}=e;getKeys(t).forEach(e=>{var e=e.split(d),t=e.length,n=e[t-1],n="*"===n?"*":code(n);if(_handlers[n]){r=r||getScope();const o=1<t?getMods(_modifier,e):[],s=[];_handlers[n]=_handlers[n].filter(e=>{var t=(!i||e.method===i)&&e.scope===r&&compareArray(e.mods,o);return t&&s.push(e.element),!t}),s.forEach(e=>removeKeyEvent(e))}})};function eventHandler(t,n,o,e){if(n.element===e){let e;if(n.scope===o||"all"===n.scope){e=0<n.mods.length;for(const s in _mods)Object.prototype.hasOwnProperty.call(_mods,s)&&(!_mods[s]&&~n.mods.indexOf(+s)||_mods[s]&&!~n.mods.indexOf(+s))&&(e=!1);(0!==n.mods.length||_mods[16]||_mods[18]||_mods[17]||_mods[91])&&!e&&"*"!==n.shortcut||(n.keys=[],n.keys=n.keys.concat(_downKeys),!1===n.method(t,n)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble)&&(t.cancelBubble=!0))}}}function dispatch(n,t){var o=_handlers["*"];let e=n.keyCode||n.which||n.charCode;if(hotkeys.filter.call(this,n)){if(93!==e&&224!==e||(e=91),~_downKeys.indexOf(e)||229===e||_downKeys.push(e),["ctrlKey","altKey","shiftKey","metaKey"].forEach(e=>{var t=modifierMap[e];n[e]&&!~_downKeys.indexOf(t)?_downKeys.push(t):!n[e]&&~_downKeys.indexOf(t)?_downKeys.splice(_downKeys.indexOf(t),1):"metaKey"!==e||!n[e]||3!==_downKeys.length||n.ctrlKey||n.shiftKey||n.altKey||(_downKeys=_downKeys.slice(_downKeys.indexOf(t)))}),e in _mods){_mods[e]=!0;for(const y in _modifier)_modifier[y]===e&&(hotkeys[y]=!0);if(!o)return}for(const p in _mods)Object.prototype.hasOwnProperty.call(_mods,p)&&(_mods[p]=n[modifierMap[p]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~_downKeys.indexOf(17)||_downKeys.push(17),~_downKeys.indexOf(18)||_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);var s=getScope();if(o)for(let e=0;e<o.length;e++)o[e].scope===s&&("keydown"===n.type&&o[e].keydown||"keyup"===n.type&&o[e].keyup)&&eventHandler(n,o[e],s,t);if(e in _handlers){var r=_handlers[e],i=r.length;for(let e=0;e<i;e++)if(("keydown"===n.type&&r[e].keydown||"keyup"===n.type&&r[e].keyup)&&r[e].key){var d=r[e],a=d["splitKey"],l=d.key.split(a),c=[];for(let e=0;e<l.length;e++)c.push(code(l[e]));c.sort().join("")===_downKeys.sort().join("")&&eventHandler(n,d,s,t)}}}}function hotkeys(e,t,n){_downKeys=[];var o,s=getKeys(e);let r=[],i="all",d=document,a=0,l=!1,c=!0,y="+",p=!1,f=!1;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(i=t.scope),t.element&&(d=t.element),t.keyup&&(l=t.keyup),void 0!==t.keydown&&(c=t.keydown),void 0!==t.capture&&(p=t.capture),"string"==typeof t.splitKey&&(y=t.splitKey),!0===t.single)&&(f=!0),"string"==typeof t&&(i=t),f&&unbind(e,i);a<s.length;a++)e=s[a].split(y),r=[],1<e.length&&(r=getMods(_modifier,e)),(e="*"===(e=e[e.length-1])?"*":code(e))in _handlers||(_handlers[e]=[]),_handlers[e].push({keyup:l,keydown:c,scope:i,mods:r,shortcut:s[a],method:n,key:s[a],splitKey:y,element:d});void 0!==d&&window&&(elementEventMap.has(d)||(t=function(){return dispatch(0<arguments.length&&void 0!==arguments[0]?arguments[0]:window.event,d)},o=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:window.event;dispatch(e,d),clearModifier(e)},elementEventMap.set(d,{keydownListener:t,keyupListenr:o,capture:p}),addEvent(d,"keydown",t,p),addEvent(d,"keyup",o,p)),winListendFocus||(t=()=>{_downKeys=[]},winListendFocus={listener:t,capture:p},addEvent(window,"focus",t,p)))}function trigger(t){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(_handlers).forEach(e=>{_handlers[e].filter(e=>e.scope===n&&e.shortcut===t).forEach(e=>{e&&e.method&&e.method()})})}function removeKeyEvent(t){var e,n,o,s=Object.values(_handlers).flat();s.findIndex(e=>{e=e.element;return e===t})<0&&({keydownListener:o,keyupListenr:n,capture:e}=elementEventMap.get(t)||{},o)&&n&&(removeEvent(t,"keyup",n,e),removeEvent(t,"keydown",o,e),elementEventMap.delete(t)),0<s.length&&0<elementEventMap.size||(Object.keys(elementEventMap).forEach(e=>{var{keydownListener:t,keyupListenr:n,capture:o}=elementEventMap.get(e)||{};t&&n&&(removeEvent(e,"keyup",n,o),removeEvent(e,"keydown",t,o),elementEventMap.delete(e))}),elementEventMap.clear(),Object.keys(_handlers).forEach(e=>delete _handlers[e]),winListendFocus&&({listener:n,capture:o}=winListendFocus,removeEvent(window,"focus",n,o),winListendFocus=null))}const _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(const L0 in _api)Object.prototype.hasOwnProperty.call(_api,L0)&&(hotkeys[L0]=_api[L0]);if("undefined"!=typeof window){const M0=window.hotkeys;hotkeys.noConflict=e=>(e&&window.hotkeys===hotkeys&&(window.hotkeys=M0),hotkeys),window.hotkeys=hotkeys}module.exports=hotkeys;
/**!
* hotkeys-js v3.13.5
* hotkeys-js v3.13.6
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.

@@ -215,4 +215,5 @@ *

let flag = true;
const isInput = tagName === 'INPUT' && !['checkbox', 'radio', 'range', 'button', 'file', 'reset', 'submit', 'color'].includes(target.type);
// ignore: isContentEditable === 'true', <input> and <textarea> when readOnly state is false, <select>
if (target.isContentEditable || (tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT') && !target.readOnly) {
if (target.isContentEditable || (isInput || tagName === 'TEXTAREA' || tagName === 'SELECT') && !target.readOnly) {
flag = false;

@@ -219,0 +220,0 @@ }

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

@@ -221,4 +221,5 @@ *

let flag = true;
const isInput = tagName === 'INPUT' && !['checkbox', 'radio', 'range', 'button', 'file', 'reset', 'submit', 'color'].includes(target.type);
// ignore: isContentEditable === 'true', <input> and <textarea> when readOnly state is false, <select>
if (target.isContentEditable || (tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT') && !target.readOnly) {
if (target.isContentEditable || (isInput || tagName === 'TEXTAREA' || tagName === 'SELECT') && !target.readOnly) {
flag = false;

@@ -225,0 +226,0 @@ }

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

/*! hotkeys-js v3.13.5 | MIT © 2024 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 y(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent&&e.attachEvent("on".concat(t),n)}function i(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.deachEvent&&e.deachEvent("on".concat(t),n)}function h(t,e){var n=e.slice(0,e.length-1);for(let e=0;e<n.length;e++)n[e]=t[n[e].toLowerCase()];return n}function m(e){var t=(e=(e="string"!=typeof e?"":e).replace(/\s/g,"")).split(",");let n=t.lastIndexOf("");for(;0<=n;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}const 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},k={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,command:91},u={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={};for(let e=1;e<20;e++)o["f".concat(e)]=111+e;let w=[],O=null,t="all";const b=new Map,E=e=>o[e.toLowerCase()]||k[e.toLowerCase()]||e.toUpperCase().charCodeAt(0);function l(e){t=e||"all"}function K(){return t||"all"}function j(n){if(void 0===n)Object.keys(v).forEach(e=>{Array.isArray(v[e])&&v[e].forEach(e=>s(e)),delete v[e]}),c(null);else if(Array.isArray(n))n.forEach(e=>{e.key&&s(e)});else if("object"==typeof n)n.key&&s(n);else if("string"==typeof n){for(var o=arguments.length,r=Array(1<o?o-1:0),i=1;i<o;i++)r[i-1]=arguments[i];let[e,t]=r;"function"==typeof e&&(t=e,e=""),s({key:n,scope:e,method:t,splitKey:"+"})}}const s=e=>{let{key:t,scope:i,method:l,splitKey:s="+"}=e;m(t).forEach(e=>{var e=e.split(s),t=e.length,n=e[t-1],n="*"===n?"*":E(n);if(v[n]){i=i||K();const o=1<t?h(k,e):[],r=[];v[n]=v[n].filter(e=>{var t=(!l||e.method===l)&&e.scope===i&&function(e,t){var n=e.length<t.length?t:e,o=e.length<t.length?e:t;let r=!0;for(let e=0;e<n.length;e++)~o.indexOf(n[e])||(r=!1);return r}(e.mods,o);return t&&r.push(e.element),!t}),r.forEach(e=>c(e))}})};function x(t,n,o,e){if(n.element===e){let e;if(n.scope===o||"all"===n.scope){e=0<n.mods.length;for(const r in g)Object.prototype.hasOwnProperty.call(g,r)&&(!g[r]&&~n.mods.indexOf(+r)||g[r]&&!~n.mods.indexOf(+r))&&(e=!1);(0!==n.mods.length||g[16]||g[18]||g[17]||g[91])&&!e&&"*"!==n.shortcut||(n.keys=[],n.keys=n.keys.concat(w),!1===n.method(t,n)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble)&&(t.cancelBubble=!0))}}}function C(n,t){var o=v["*"];let e=n.keyCode||n.which||n.charCode;if(L.filter.call(this,n)){if(93!==e&&224!==e||(e=91),~w.indexOf(e)||229===e||w.push(e),["ctrlKey","altKey","shiftKey","metaKey"].forEach(e=>{var t=u[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)))}),e in g){g[e]=!0;for(const d in k)k[d]===e&&(L[d]=!0);if(!o)return}for(const p in g)Object.prototype.hasOwnProperty.call(g,p)&&(g[p]=n[u[p]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~w.indexOf(17)||w.push(17),~w.indexOf(18)||w.push(18),g[17]=!0,g[18]=!0);var r=K();if(o)for(let e=0;e<o.length;e++)o[e].scope===r&&("keydown"===n.type&&o[e].keydown||"keyup"===n.type&&o[e].keyup)&&x(n,o[e],r,t);if(e in v){var i=v[e],l=i.length;for(let e=0;e<l;e++)if(("keydown"===n.type&&i[e].keydown||"keyup"===n.type&&i[e].keyup)&&i[e].key){var s=i[e],c=s["splitKey"],a=s.key.split(c),f=[];for(let e=0;e<a.length;e++)f.push(E(a[e]));f.sort().join("")===w.sort().join("")&&x(n,s,r,t)}}}}function L(e,t,n){w=[];var o,r=m(e);let i=[],l="all",s=document,c=0,a=!1,f=!0,d="+",p=!1,u=!1;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(l=t.scope),t.element&&(s=t.element),t.keyup&&(a=t.keyup),void 0!==t.keydown&&(f=t.keydown),void 0!==t.capture&&(p=t.capture),"string"==typeof t.splitKey&&(d=t.splitKey),!0===t.single)&&(u=!0),"string"==typeof t&&(l=t),u&&j(e,l);c<r.length;c++)e=r[c].split(d),i=[],1<e.length&&(i=h(k,e)),(e="*"===(e=e[e.length-1])?"*":E(e))in v||(v[e]=[]),v[e].push({keyup:a,keydown:f,scope:l,mods:i,shortcut:r[c],method:n,key:r[c],splitKey:d,element:s});void 0!==s&&window&&(b.has(s)||(t=function(){return C(0<arguments.length&&void 0!==arguments[0]?arguments[0]:window.event,s)},o=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:window.event;C(t,s);{let e=t.keyCode||t.which||t.charCode;var n=w.indexOf(e);if(n<0||w.splice(n,1),t.key&&"meta"==t.key.toLowerCase()&&w.splice(0,w.length),(e=93!==e&&224!==e?e:91)in g){g[e]=!1;for(const o in k)k[o]===e&&(L[o]=!1)}}},b.set(s,{keydownListener:t,keyupListenr:o,capture:p}),y(s,"keydown",t,p),y(s,"keyup",o,p)),O||(t=()=>{w=[]},O={listener:t,capture:p},y(window,"focus",t,p)))}function c(t){var e,n,o,r=Object.values(v).flat();r.findIndex(e=>{e=e.element;return e===t})<0&&({keydownListener:o,keyupListenr:n,capture:e}=b.get(t)||{},o)&&n&&(i(t,"keyup",n,e),i(t,"keydown",o,e),b.delete(t)),0<r.length&&0<b.size||(Object.keys(b).forEach(e=>{var{keydownListener:t,keyupListenr:n,capture:o}=b.get(e)||{};t&&n&&(i(e,"keyup",n,o),i(e,"keydown",t,o),b.delete(e))}),b.clear(),Object.keys(v).forEach(e=>delete v[e]),O&&({listener:n,capture:o}=O,i(window,"focus",n,o),O=null))}var n={getPressedKeyString:function(){return w.map(e=>{return n=e,Object.keys(o).find(e=>o[e]===n)||(t=e,Object.keys(k).find(e=>k[e]===t))||String.fromCharCode(e);var t,n})},setScope:l,getScope:K,deleteScope:function(e,t){var n;let o;e=e||K();for(const r in 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).forEach(e=>{e=e.element;return c(e)}):o++;K()===e&&l(t||"all")},getPressedKeyCodes:function(){return w.slice(0)},getAllKeyCodes:function(){const r=[];return Object.keys(v).forEach(e=>{v[e].forEach(e=>{var{key:e,scope:t,mods:n,shortcut:o}=e;r.push({scope:t,shortcut:o,mods:n,keys:e.split("+").map(e=>E(e))})})}),r},isPressed:function(e){return"string"==typeof e&&(e=E(e)),!!~w.indexOf(e)},filter:function(e){var t=(e=e.target||e.srcElement)["tagName"];let n=!e.isContentEditable&&("INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t||e.readOnly)?!0:!1;return n},trigger:function(t){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(v).forEach(e=>{v[e].filter(e=>e.scope===n&&e.shortcut===t).forEach(e=>{e&&e.method&&e.method()})})},unbind:j,keyMap:o,modifier:k,modifierMap:u};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(L[r]=n[r]);if("undefined"!=typeof window){const a=window.hotkeys;L.noConflict=e=>(e&&window.hotkeys===L&&(window.hotkeys=a),L),window.hotkeys=L}return L});
/*! hotkeys-js v3.13.6 | MIT © 2024 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 y(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent&&e.attachEvent("on".concat(t),n)}function i(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.deachEvent&&e.deachEvent("on".concat(t),n)}function h(t,e){var n=e.slice(0,e.length-1);for(let e=0;e<n.length;e++)n[e]=t[n[e].toLowerCase()];return n}function m(e){var t=(e=(e="string"!=typeof e?"":e).replace(/\s/g,"")).split(",");let n=t.lastIndexOf("");for(;0<=n;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}const 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},k={"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,command:91},p={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={};for(let e=1;e<20;e++)o["f".concat(e)]=111+e;let w=[],O=null,t="all";const b=new Map,E=e=>o[e.toLowerCase()]||k[e.toLowerCase()]||e.toUpperCase().charCodeAt(0);function l(e){t=e||"all"}function K(){return t||"all"}function x(n){if(void 0===n)Object.keys(v).forEach(e=>{Array.isArray(v[e])&&v[e].forEach(e=>s(e)),delete v[e]}),c(null);else if(Array.isArray(n))n.forEach(e=>{e.key&&s(e)});else if("object"==typeof n)n.key&&s(n);else if("string"==typeof n){for(var o=arguments.length,r=Array(1<o?o-1:0),i=1;i<o;i++)r[i-1]=arguments[i];let[e,t]=r;"function"==typeof e&&(t=e,e=""),s({key:n,scope:e,method:t,splitKey:"+"})}}const s=e=>{let{key:t,scope:i,method:l,splitKey:s="+"}=e;m(t).forEach(e=>{var e=e.split(s),t=e.length,n=e[t-1],n="*"===n?"*":E(n);if(v[n]){i=i||K();const o=1<t?h(k,e):[],r=[];v[n]=v[n].filter(e=>{var t=(!l||e.method===l)&&e.scope===i&&function(e,t){var n=e.length<t.length?t:e,o=e.length<t.length?e:t;let r=!0;for(let e=0;e<n.length;e++)~o.indexOf(n[e])||(r=!1);return r}(e.mods,o);return t&&r.push(e.element),!t}),r.forEach(e=>c(e))}})};function j(t,n,o,e){if(n.element===e){let e;if(n.scope===o||"all"===n.scope){e=0<n.mods.length;for(const r in g)Object.prototype.hasOwnProperty.call(g,r)&&(!g[r]&&~n.mods.indexOf(+r)||g[r]&&!~n.mods.indexOf(+r))&&(e=!1);(0!==n.mods.length||g[16]||g[18]||g[17]||g[91])&&!e&&"*"!==n.shortcut||(n.keys=[],n.keys=n.keys.concat(w),!1===n.method(t,n)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble)&&(t.cancelBubble=!0))}}}function C(n,t){var o=v["*"];let e=n.keyCode||n.which||n.charCode;if(L.filter.call(this,n)){if(93!==e&&224!==e||(e=91),~w.indexOf(e)||229===e||w.push(e),["ctrlKey","altKey","shiftKey","metaKey"].forEach(e=>{var t=p[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)))}),e in g){g[e]=!0;for(const d in k)k[d]===e&&(L[d]=!0);if(!o)return}for(const u in g)Object.prototype.hasOwnProperty.call(g,u)&&(g[u]=n[p[u]]);n.getModifierState&&(!n.altKey||n.ctrlKey)&&n.getModifierState("AltGraph")&&(~w.indexOf(17)||w.push(17),~w.indexOf(18)||w.push(18),g[17]=!0,g[18]=!0);var r=K();if(o)for(let e=0;e<o.length;e++)o[e].scope===r&&("keydown"===n.type&&o[e].keydown||"keyup"===n.type&&o[e].keyup)&&j(n,o[e],r,t);if(e in v){var i=v[e],l=i.length;for(let e=0;e<l;e++)if(("keydown"===n.type&&i[e].keydown||"keyup"===n.type&&i[e].keyup)&&i[e].key){var s=i[e],c=s["splitKey"],a=s.key.split(c),f=[];for(let e=0;e<a.length;e++)f.push(E(a[e]));f.sort().join("")===w.sort().join("")&&j(n,s,r,t)}}}}function L(e,t,n){w=[];var o,r=m(e);let i=[],l="all",s=document,c=0,a=!1,f=!0,d="+",u=!1,p=!1;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(l=t.scope),t.element&&(s=t.element),t.keyup&&(a=t.keyup),void 0!==t.keydown&&(f=t.keydown),void 0!==t.capture&&(u=t.capture),"string"==typeof t.splitKey&&(d=t.splitKey),!0===t.single)&&(p=!0),"string"==typeof t&&(l=t),p&&x(e,l);c<r.length;c++)e=r[c].split(d),i=[],1<e.length&&(i=h(k,e)),(e="*"===(e=e[e.length-1])?"*":E(e))in v||(v[e]=[]),v[e].push({keyup:a,keydown:f,scope:l,mods:i,shortcut:r[c],method:n,key:r[c],splitKey:d,element:s});void 0!==s&&window&&(b.has(s)||(t=function(){return C(0<arguments.length&&void 0!==arguments[0]?arguments[0]:window.event,s)},o=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:window.event;C(t,s);{let e=t.keyCode||t.which||t.charCode;var n=w.indexOf(e);if(n<0||w.splice(n,1),t.key&&"meta"==t.key.toLowerCase()&&w.splice(0,w.length),(e=93!==e&&224!==e?e:91)in g){g[e]=!1;for(const o in k)k[o]===e&&(L[o]=!1)}}},b.set(s,{keydownListener:t,keyupListenr:o,capture:u}),y(s,"keydown",t,u),y(s,"keyup",o,u)),O||(t=()=>{w=[]},O={listener:t,capture:u},y(window,"focus",t,u)))}function c(t){var e,n,o,r=Object.values(v).flat();r.findIndex(e=>{e=e.element;return e===t})<0&&({keydownListener:o,keyupListenr:n,capture:e}=b.get(t)||{},o)&&n&&(i(t,"keyup",n,e),i(t,"keydown",o,e),b.delete(t)),0<r.length&&0<b.size||(Object.keys(b).forEach(e=>{var{keydownListener:t,keyupListenr:n,capture:o}=b.get(e)||{};t&&n&&(i(e,"keyup",n,o),i(e,"keydown",t,o),b.delete(e))}),b.clear(),Object.keys(v).forEach(e=>delete v[e]),O&&({listener:n,capture:o}=O,i(window,"focus",n,o),O=null))}var n={getPressedKeyString:function(){return w.map(e=>{return n=e,Object.keys(o).find(e=>o[e]===n)||(t=e,Object.keys(k).find(e=>k[e]===t))||String.fromCharCode(e);var t,n})},setScope:l,getScope:K,deleteScope:function(e,t){var n;let o;e=e||K();for(const r in 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).forEach(e=>{e=e.element;return c(e)}):o++;K()===e&&l(t||"all")},getPressedKeyCodes:function(){return w.slice(0)},getAllKeyCodes:function(){const r=[];return Object.keys(v).forEach(e=>{v[e].forEach(e=>{var{key:e,scope:t,mods:n,shortcut:o}=e;r.push({scope:t,shortcut:o,mods:n,keys:e.split("+").map(e=>E(e))})})}),r},isPressed:function(e){return"string"==typeof e&&(e=E(e)),!!~w.indexOf(e)},filter:function(e){var t=(e=e.target||e.srcElement)["tagName"];let n=!0;var o="INPUT"===t&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(e.type);return n=!e.isContentEditable&&(!o&&"TEXTAREA"!==t&&"SELECT"!==t||e.readOnly)?n:!1},trigger:function(t){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(v).forEach(e=>{v[e].filter(e=>e.scope===n&&e.shortcut===t).forEach(e=>{e&&e.method&&e.method()})})},unbind:x,keyMap:o,modifier:k,modifierMap:p};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(L[r]=n[r]);if("undefined"!=typeof window){const a=window.hotkeys;L.noConflict=e=>(e&&window.hotkeys===L&&(window.hotkeys=a),L),window.hotkeys=L}return L});
{
"name": "hotkeys-js",
"description": "A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.",
"version": "3.13.5",
"version": "3.13.6",
"main": "index.js",

@@ -6,0 +6,0 @@ "types": "index.d.ts",

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