1
/*!
2
* hotkeys-js v3.8.1
3
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
4
*
5
* Copyright (c) 2020 kenny wong <wowohoo@qq.com>
6
* http://jaywcjlove.github.io/hotkeys
7
*
8
* Licensed under the MIT license.
9
*/
10
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).hotkeys=t()}
11
(this,(function(){"use strict";var e="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")>0;function t(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on".concat(t),(function(){n(window.event)}
12
))}
13
function n(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}
14
function o(e){"string"!=typeof e&&(e="");for(var t=(e=e.replace(/\s/g,"")).split(","),n=t.lastIndexOf("");n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}
15
for(var r={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,"⇪":20,",":188,".":190,"/":191,"`":192,"-":e?173:189,"=":e?61:187,";":e?59:186,"'":222,"[":219,"]":221,"\\":220}
16
,i={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91}
17
,f={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91}
18
,a={16:!1,18:!1,17:!1,91:!1}
19
,c={}
20
,l=1;l<20;l++)r["f".concat(l)]=111+l;var s=[],p="all",y=[],d=function(e){return r[e.toLowerCase()]||i[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)}
21
;function u(e){p=e||"all"}
22
function h(){return p||"all"}
23
var v=function(e){var t=e.key,r=e.scope,f=e.method,a=e.splitKey,l=void 0===a?"+":a;o(t).forEach((function(e){var t=e.split(l),o=t.length,a=t[o-1],s="*"===a?"*":d(a);if(c[s]){r||(r=h());var p=o>1?n(i,t):[];c[s]=c[s].map((function(e){return(!f||e.method===f)&&e.scope===r&&function(e,t){for(var n=e.length>=t.length?e:t,o=e.length>=t.length?t:e,r=!0,i=0;i<n.length;i++)-1===o.indexOf(n[i])&&(r=!1);return r}
24
(e.mods,p)?{}
25
:e}
26
))}
27
}
28
))}
29
;function g(e,t,n){var o;if(t.scope===n||"all"===t.scope){for(var r in o=t.mods.length>0,a)Object.prototype.hasOwnProperty.call(a,r)&&(!a[r]&&t.mods.indexOf(+r)>-1||a[r]&&-1===t.mods.indexOf(+r))&&(o=!1);(0!==t.mods.length||a[16]||a[18]||a[17]||a[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))}
30
}
31
function w(e){var t=c["*"],n=e.keyCode||e.which||e.charCode;if(k.filter.call(this,e)){if(93!==n&&224!==n||(n=91),-1===s.indexOf(n)&&229!==n&&s.push(n),["ctrlKey","altKey","shiftKey","metaKey"].forEach((function(t){var n=f[t];e[t]&&-1===s.indexOf(n)?s.push(n):!e[t]&&s.indexOf(n)>-1?s.splice(s.indexOf(n),1):"metaKey"===t&&e[t]&&3===s.length&&(e.ctrlKey||e.shiftKey||e.altKey||(s=s.slice(s.indexOf(n))))}
32
)),n in a){for(var o in a[n]=!0,i)i[o]===n&&(k[o]=!0);if(!t)return}
33
for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(a[r]=e[f[r]]);e.getModifierState&&(!e.altKey||e.ctrlKey)&&e.getModifierState("AltGraph")&&(-1===s.indexOf(17)&&s.push(17),-1===s.indexOf(18)&&s.push(18),a[17]=!0,a[18]=!0);var l=h();if(t)for(var p=0;p<t.length;p++)t[p].scope===l&&("keydown"===e.type&&t[p].keydown||"keyup"===e.type&&t[p].keyup)&&g(e,t[p],l);if(n in c)for(var y=0;y<c[n].length;y++)if(("keydown"===e.type&&c[n][y].keydown||"keyup"===e.type&&c[n][y].keyup)&&c[n][y].key){for(var u=c[n][y],v=u.splitKey,w=u.key.split(v),m=[],O=0;O<w.length;O++)m.push(d(w[O]));m.sort().join("")===s.sort().join("")&&g(e,u,l)}
34
}
35
}
36
function k(e,r,f){s=[];var l=o(e),p=[],u="all",h=document,v=0,g=!1,m=!0,O="+";for(void 0===f&&"function"==typeof r&&(f=r),"[object Object]"===Object.prototype.toString.call(r)&&(r.scope&&(u=r.scope),r.element&&(h=r.element),r.keyup&&(g=r.keyup),void 0!==r.keydown&&(m=r.keydown),"string"==typeof r.splitKey&&(O=r.splitKey)),"string"==typeof r&&(u=r);v<l.length;v++)p=[],(e=l[v].split(O)).length>1&&(p=n(i,e)),(e="*"===(e=e[e.length-1])?"*":d(e))in c||(c[e]=[]),c[e].push({keyup:g,keydown:m,scope:u,mods:p,shortcut:l[v],method:f,key:l[v],splitKey:O}
37
);void 0!==h&&!function(e){return y.indexOf(e)>-1}
38
(h)&&window&&(y.push(h),t(h,"keydown",(function(e){w(e)}
39
)),t(window,"focus",(function(){s=[]}
40
)),t(h,"keyup",(function(e){w(e),function(e){var t=e.keyCode||e.which||e.charCode,n=s.indexOf(t);if(n>=0&&s.splice(n,1),e.key&&"meta"===e.key.toLowerCase()&&s.splice(0,s.length),93!==t&&224!==t||(t=91),t in a)for(var o in a[t]=!1,i)i[o]===t&&(k[o]=!1)}
...
</html>