From d1f7cbbb3962cab3c8f9a946a07899412da5cbec Mon Sep 17 00:00:00 2001 From: Martin Rocek Date: Fri, 28 May 2021 10:47:30 +0200 Subject: [PATCH 1/2] Fix numerical key bindings on different keyboard layouts --- src/client/js/input.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/client/js/input.js b/src/client/js/input.js index 69c73eef..23ea325f 100644 --- a/src/client/js/input.js +++ b/src/client/js/input.js @@ -22,6 +22,14 @@ define([ 'shift', 'ctrl' ], + numericalKeyCodeMappings: { + Digit1: 49, + Digit2: 50, + Digit3: 51, + Digit4: 52, + Digit5: 53 + }, + mappings: { 8: 'backspace', 9: 'tab', @@ -73,7 +81,7 @@ define([ onLoadShake: function (shake) { let shaker = new shake({ threshold: 5, - timeout: 1000 + timeout: 1000 }); shaker.start(); @@ -81,7 +89,7 @@ define([ }, resetKeys: function () { - for (let k in this.keys) + for (let k in this.keys) events.emit('onKeyUp', k); this.keys = {}; @@ -103,7 +111,7 @@ define([ return true; let down = this.keys[key]; - + this.keys[key] = 2; return (down === 1); } return false; @@ -138,7 +146,8 @@ define([ if (!this.enabled) return; - let key = this.getMapping(e.which); + let code = this.numericalKeyCodeMappings[e.code] || e.which; + let key = this.getMapping(code); let isModifier = this.modifiers.indexOf(key) > -1; let isBody = e.target === document.body; @@ -176,7 +185,7 @@ define([ let key = this.getMapping(e.which); let isModifier = this.modifiers.indexOf(key) > -1; let isBody = e.target === document.body; - + if (!isModifier && !isBody) return; @@ -271,7 +280,7 @@ define([ let el = $(e.target); if ((!el.hasClass('ui-container')) || (el.hasClass('blocking'))) return; - + events.emit('onTouchCancel'); } }, @@ -283,4 +292,4 @@ define([ } } }; -}); +}); \ No newline at end of file From 21794b54417975d415a8e18dd44b73a2ae10e60f Mon Sep 17 00:00:00 2001 From: Martin Rocek Date: Fri, 28 May 2021 10:52:33 +0200 Subject: [PATCH 2/2] Add new line at the end of input.js --- src/client/js/input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/js/input.js b/src/client/js/input.js index 23ea325f..1e542fbd 100644 --- a/src/client/js/input.js +++ b/src/client/js/input.js @@ -292,4 +292,4 @@ define([ } } }; -}); \ No newline at end of file +});