mockm
Version:
Analog interface server, painless parallel development of front and back ends.
8 lines • 2.53 kB
JavaScript
/**
* Minified by jsDelivr using Terser v5.13.1.
* Original file: /gh/Web-Engine/hot-key-lib@master/src/hot-key-lib.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
function HotKey(){const t={8:"BACK-SPACE",9:"TAB",12:"NUMPAD-CENTER",13:"ENTER",16:"SHIFT",17:"CTRL",18:"ALT",19:"PAUSE-BREAK",20:"CAPS-LOCK",27:"ESC",32:"SPACE",33:"PAGE-UP",34:"PAGE-DOWN",35:"END",36:"HOME",37:"LEFT-ARROW",38:"UP-ARROW",39:"RIGHT-ARROW",40:"DOWN-ARROW",44:"PRINT-SCREEN",45:"INSERT",46:"DELETE",91:"META",92:"META",93:"SELECT",106:"NUMPAD-*",107:"NUMPAD-+",109:"NUMPAD--",110:"NUMPAD-.",111:"NUMPAD-/",144:"NUM-LOCK",145:"SCROLL-LOCK",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"};var e={ALL:[]},n={preventDefault:!1,metaToCtrl:!1,noNumpadNum:!1};function r(t){return t.keyCode||t.which}function o(e){var o=r(e);return t[o]?t[o]:96<=o&&o<=105?n.noNumpadNum?(o-96).toString():"NUMPAD-"+(o-96):112<=o&&o<=123?"F"+(o-111):String.fromCharCode(o)}function i(t){var i=function(t){var e=r(t),i=[];return t.ctrlKey&&i.push("CTRL"),t.metaKey&&(n.metaToCtrl?t.ctrlKey||i.push("CTRL"):i.push("META")),t.shiftKey&&i.push("SHIFT"),t.altKey&&i.push("ALT"),16==e||17==e||18==e||91==e||92==e||i.push(o(t)),i.join("+")}(t),a=o(t),f=r(t);t.which=f,t.keyCode=f,t.keyFullString=i,t.keyString=a,e.ALL.forEach((function(e){e.call(document,t)})),e[i]&&(n.preventDefault&&t.preventDefault(),e[i].forEach((function(e){e.call(document,t)})))}function a(t){t.addEventListener?t.addEventListener("keydown",i):t.attachEvent&&t.attachEvent("onkeydown",i)}function f(t){t.removeEventListener?t.removeEventListener("keydown",i):t.detachEvent&&t.detachEvent("onkeydown",i)}this.add=function(t,n){if(t instanceof Array){var r=this;t.forEach((function(t){r.add(t,n)}))}else t=t.toString().toUpperCase(),e[t]||(e[t]=[]),e[t].push(n)},this.remove=function(t,n){if(t instanceof Array){var r=this;t.forEach((function(t){r.remove(t,n)}))}else if(t=t.toString().toUpperCase(),e[t])if(n){var o=e[t].indexOf(n);if(o<0)return;e[t].splice(o,1)}else delete e[t]},this.setup=function(t){for(var e in t)n[e]=t},this.start=function(t){if(null==t&&(t=document),this.target=t,t instanceof Array)for(var e=0;e<t.length;e++)a(t[e]);else a(t)},this.stop=function(){if(this.target instanceof Array)for(var t=0;t<this.target.length;t++)f(this.target[t]);else f(this.target)}}
//# sourceMappingURL=/sm/ec3b76c908a8c6e4b5a146cbd8552fc8634c91867310383a79814373f1e18ce5.map