1
0
web/static/pkg/hotkeys-js/dist/hotkeys.min.js

2 lines
7.4 KiB
JavaScript
Raw Normal View History

2024-04-05 08:46:22 +00:00
/*! hotkeys-js v3.13.7 | 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.detachEvent&&e.detachEvent("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=