From 652f2c591eb4fa1768d3d67ecae7b5dc1e633213 Mon Sep 17 00:00:00 2001 From: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> Date: Tue, 30 Nov 2021 23:54:40 -0500 Subject: [PATCH] Numpad keys will now be recognised by the keybinds menu (#63128) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Co-authored-by: Aleksej Komarov --- .../tgui/interfaces/PreferencesMenu/KeybindingsPage.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/KeybindingsPage.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/KeybindingsPage.tsx index e80bfef0f6c..24ad1946d2c 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/KeybindingsPage.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/KeybindingsPage.tsx @@ -49,6 +49,13 @@ const KEY_CODE_TO_BYOND: Record = { "UP": "North", }; +/** + * So, as it turns out, KeyboardEvent seems to be broken with IE 11, the + * DOM_KEY_LOCATION_X codes are all undefined. See this to see why it's 3: + * https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/location + */ +const DOM_KEY_LOCATION_NUMPAD = 3; + const sortKeybindings = sortBy( ([_, keybinding]: [string, Keybinding]) => { return keybinding.name; @@ -74,7 +81,7 @@ const formatKeyboardEvent = (event: KeyboardEvent): string => { text += "Shift"; } - if (event.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD) { + if (event.location === DOM_KEY_LOCATION_NUMPAD) { text += "Numpad"; }