From 6600c97b2fa478261b21270948fae1868f09e8d4 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Fri, 3 Dec 2021 18:37:49 -0700 Subject: [PATCH] (try to) start shortcuts --- .editorconfig | 10 ++++++++++ json/shortcuts.json | 4 ++++ scripts/dep/mousetrap.js | 11 +++++++++++ scripts/keybinds/handle.js | 9 +++++++++ scripts/keybinds/reload.js | 4 ++++ 5 files changed, 38 insertions(+) create mode 100644 .editorconfig create mode 100644 json/shortcuts.json create mode 100644 scripts/dep/mousetrap.js create mode 100644 scripts/keybinds/handle.js create mode 100644 scripts/keybinds/reload.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3d8ad22 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +charset = utf-8 +end_of_line = crlf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 120 +tab_width = 4 diff --git a/json/shortcuts.json b/json/shortcuts.json new file mode 100644 index 0000000..edac5e1 --- /dev/null +++ b/json/shortcuts.json @@ -0,0 +1,4 @@ +{ + "ctrl+r": "reload", + "command+r": "reload" +} \ No newline at end of file diff --git a/scripts/dep/mousetrap.js b/scripts/dep/mousetrap.js new file mode 100644 index 0000000..185c42f --- /dev/null +++ b/scripts/dep/mousetrap.js @@ -0,0 +1,11 @@ +/* mousetrap v1.6.5 craig.is/killing/mice */ +(function(q,u,c){function v(a,b,g){a.addEventListener?a.addEventListener(b,g,!1):a.attachEvent("on"+b,g)}function z(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return n[a.which]?n[a.which]:r[a.which]?r[a.which]:String.fromCharCode(a.which).toLowerCase()}function F(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function w(a){return"shift"==a||"ctrl"==a||"alt"==a|| +"meta"==a}function A(a,b){var g,d=[];var e=a;"+"===e?e=["+"]:(e=e.replace(/\+{2}/g,"+plus"),e=e.split("+"));for(g=0;gc||n.hasOwnProperty(c)&&(p[n[c]]=c)}g=p[e]?"keydown":"keypress"}"keypress"==g&&d.length&&(g="keydown");return{key:m,modifiers:d,action:g}}function D(a,b){return null===a||a===u?!1:a===b?!0:D(a.parentNode,b)}function d(a){function b(a){a= +a||{};var b=!1,l;for(l in p)a[l]?b=!0:p[l]=0;b||(x=!1)}function g(a,b,t,f,g,d){var l,E=[],h=t.type;if(!k._callbacks[a])return[];"keyup"==h&&w(a)&&(b=[a]);for(l=0;l":".","?":"/","|":"\\"},B={option:"alt",command:"meta","return":"enter", +escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p;for(c=1;20>c;++c)n[111+c]="f"+c;for(c=0;9>=c;++c)n[c+96]=c.toString();d.prototype.bind=function(a,b,c){a=a instanceof Array?a:[a];this._bindMultiple.call(this,a,b,c);return this};d.prototype.unbind=function(a,b){return this.bind.call(this,a,function(){},b)};d.prototype.trigger=function(a,b){if(this._directMap[a+":"+b])this._directMap[a+":"+b]({},a);return this};d.prototype.reset=function(){this._callbacks={}; +this._directMap={};return this};d.prototype.stopCallback=function(a,b){if(-1<(" "+b.className+" ").indexOf(" mousetrap ")||D(b,this.target))return!1;if("composedPath"in a&&"function"===typeof a.composedPath){var c=a.composedPath()[0];c!==a.target&&(b=c)}return"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable};d.prototype.handleKey=function(){return this._handleKey.apply(this,arguments)};d.addKeycodes=function(a){for(var b in a)a.hasOwnProperty(b)&&(n[b]=a[b]);p=null}; +d.init=function(){var a=d(u),b;for(b in a)"_"!==b.charAt(0)&&(d[b]=function(b){return function(){return a[b].apply(a,arguments)}}(b))};d.init();q.Mousetrap=d;"undefined"!==typeof module&&module.exports&&(module.exports=d);"function"===typeof define&&define.amd&&define(function(){return d})}})("undefined"!==typeof window?window:null,"undefined"!==typeof window?document:null); diff --git a/scripts/keybinds/handle.js b/scripts/keybinds/handle.js new file mode 100644 index 0000000..0c69fa6 --- /dev/null +++ b/scripts/keybinds/handle.js @@ -0,0 +1,9 @@ +const mousetrap = require('../dep/mousetrap'); + +const binds = require('../../json/shortcuts.json'); + +module.exports = () => { + Object.keys(binds).forEach((bind) => { + mousetrap.bind(bind, require(`./${binds[bind]}.js`)); + }); +}; \ No newline at end of file diff --git a/scripts/keybinds/reload.js b/scripts/keybinds/reload.js new file mode 100644 index 0000000..2a81619 --- /dev/null +++ b/scripts/keybinds/reload.js @@ -0,0 +1,4 @@ +module.exports = () => { + window.reload(); + console.log('e'); +}; \ No newline at end of file