From 0481c84e724ffa61f62b19b78839751ad51aeac5 Mon Sep 17 00:00:00 2001 From: EmeraldBlock <69981203+EmeraldBlock@users.noreply.github.com> Date: Sun, 4 Oct 2020 03:34:40 -0500 Subject: [PATCH] "Fix" getStringForKeyCode returning incorrect strings (#753) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix getStringForKeyCode returning wrong result This adds the full stop/period (.) key to the switch statement, and replaces String.fromCharCode (which works with Unicode) with the replacement character (�). * Make letter keys work properly * Add digits and display unknown codes in brackets * better formatting --- src/js/game/key_action_mapper.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/game/key_action_mapper.js b/src/js/game/key_action_mapper.js index 9c1b2f96..872db1d2 100644 --- a/src/js/game/key_action_mapper.js +++ b/src/js/game/key_action_mapper.js @@ -248,6 +248,8 @@ export function getStringForKeyCode(code) { return ","; case 189: return "-"; + case 190: + return "."; case 191: return "/"; case 219: @@ -260,7 +262,9 @@ export function getStringForKeyCode(code) { return "'"; } - return String.fromCharCode(code); + return (48 <= code && code <= 57) || (65 <= code && code <= 90) + ? String.fromCharCode(code) + : "[" + code + "]"; } export class Keybinding {