/*! * hotkeys-js v3.8.1 * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. * * Copyright (c) 2020 kenny wong * http://jaywcjlove.github.io/hotkeys * * Licensed under the MIT license. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).hotkeys=t()}(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)}))}function n(e,t){for(var n=t.slice(0,t.length-1),o=0;o=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}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},i={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},f={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},a={16:!1,18:!1,17:!1,91:!1},c={},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)};function u(e){p=e||"all"}function h(){return p||"all"}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;i0,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))}}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))))})),n in a){for(var o in a[n]=!0,i)i[o]===n&&(k[o]=!0);if(!t)return}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;p1&&(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});void 0!==h&&!function(e){return y.indexOf(e)>-1}(h)&&window&&(y.push(h),t(h,"keydown",(function(e){w(e)})),t(window,"focus",(function(){s=[]})),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)}(e)})))}var m={setScope:u,getScope:h,deleteScope:function(e,t){var n,o;for(var r in e||(e=h()),c)if(Object.prototype.hasOwnProperty.call(c,r))for(n=c[r],o=0;o1?t-1:0),o=1;o