diff --git a/code/modules/client/tgui_macro.dm b/code/modules/client/tgui_macro.dm index cd621cebab84..28939fed69ca 100644 --- a/code/modules/client/tgui_macro.dm +++ b/code/modules/client/tgui_macro.dm @@ -23,11 +23,12 @@ GLOBAL_LIST_EMPTY(ui_data_keybindings) /datum/tgui_macro/ui_data(mob/user) . = list() - .["keybinds"] = prefs.key_bindings + .["player_keybinds"] = prefs.key_bindings /datum/tgui_macro/ui_static_data(mob/user) . = list() .["glob_keybinds"] = GLOB.ui_data_keybindings + .["byond_keymap"] = GLOB._kbMap /datum/tgui_macro/ui_state(mob/user) return GLOB.always_state diff --git a/tgui/packages/tgui/interfaces/KeyBinds.jsx b/tgui/packages/tgui/interfaces/KeyBinds.jsx index 63fc25aca3c5..b387d6a8dba5 100644 --- a/tgui/packages/tgui/interfaces/KeyBinds.jsx +++ b/tgui/packages/tgui/interfaces/KeyBinds.jsx @@ -18,7 +18,7 @@ const getAllKeybinds = (glob_keybinds) => { export const KeyBinds = (props) => { const { act, data } = useBackend(); - const { glob_keybinds } = data; + const { player_keybinds, glob_keybinds, byond_keymap } = data; const [selectedTab, setSelectedTab] = useLocalState('progress', 'ALL'); @@ -52,13 +52,38 @@ export const KeyBinds = (props) => { }> - - setSearchTerm(value)} - placeholder="Search..." - fluid - /> + + + setSearchTerm(value)} + placeholder="Search..." + fluid + /> + + + { + // The key(s) pressed by the user, byond-ified. + const targetKey = keysDown + .map((k) => byond_keymap[k] || k) + .join('+'); + // targetKey's entry in player_keybinds. + const targetEntry = player_keybinds[targetKey]; + if (!targetEntry) { + return; + } + // If a keybind was found, scroll to the first match. + document + .getElementById(targetEntry[0]) + .scrollIntoView(); + }} + /> + + @@ -129,11 +154,11 @@ const KeybindsDropdown = (props) => { export const KeybindElement = (props) => { const { act, data } = useBackend(); const { keybind } = props; - const { keybinds } = data; + const { player_keybinds } = data; const currentBoundKeys = []; - for (const [key, value] of Object.entries(keybinds)) { + for (const [key, value] of Object.entries(player_keybinds)) { for (let i = 0; i < value.length; i++) { if (value[i] === keybind.name) { currentBoundKeys.push(key); @@ -143,7 +168,7 @@ export const KeybindElement = (props) => { } return ( - + {keybind.full_name}