diff --git a/code/modules/client/tgui_macro.dm b/code/modules/client/tgui_macro.dm index 684cf90942ea..f245f1d657d4 100644 --- a/code/modules/client/tgui_macro.dm +++ b/code/modules/client/tgui_macro.dm @@ -45,6 +45,7 @@ GLOBAL_LIST_EMPTY(ui_data_keybindings) if(!ui) ui = new(user, src, "KeyBinds", "Keybind Preference") ui.open() + ui.set_autoupdate(FALSE) /datum/tgui_macro/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) . = ..() diff --git a/tgui/packages/tgui/events.js b/tgui/packages/tgui/events.js index a0bc2ab2da32..6eb4351194b7 100644 --- a/tgui/packages/tgui/events.js +++ b/tgui/packages/tgui/events.js @@ -203,7 +203,7 @@ document.addEventListener('keydown', (e) => { if (canStealFocus(e.target)) { return; } - const code = e.keyCode; + const code = e.code; const key = new KeyEvent(e, 'keydown', keyHeldByCode[code]); globalEvents.emit('keydown', key); globalEvents.emit('key', key); @@ -214,7 +214,7 @@ document.addEventListener('keyup', (e) => { if (canStealFocus(e.target)) { return; } - const code = e.keyCode; + const code = e.code; const key = new KeyEvent(e, 'keyup'); globalEvents.emit('keyup', key); globalEvents.emit('key', key); diff --git a/tgui/packages/tgui/hotkeys.ts b/tgui/packages/tgui/hotkeys.ts index f7176bd00300..2f6579a377f4 100644 --- a/tgui/packages/tgui/hotkeys.ts +++ b/tgui/packages/tgui/hotkeys.ts @@ -73,7 +73,10 @@ const keyCodeToByond = (keyCode: number) => { const handlePassthrough = (key: KeyEvent) => { const keyString = String(key); // In addition to F5, support reloading with Ctrl+R and Ctrl+F5 - if (keyString === 'Ctrl+F5' || keyString === 'Ctrl+R') { + if ( + !key.event.defaultPrevented && + (keyString === 'Ctrl+F5' || keyString === 'Ctrl+R') + ) { location.reload(); return; } diff --git a/tgui/packages/tgui/interfaces/KeyBinds.js b/tgui/packages/tgui/interfaces/KeyBinds.js index 6f3841ceb0ab..f3319b725456 100644 --- a/tgui/packages/tgui/interfaces/KeyBinds.js +++ b/tgui/packages/tgui/interfaces/KeyBinds.js @@ -3,7 +3,6 @@ import { useBackend, useLocalState } from '../backend'; import { Button, Flex, Section, Box, Input, Dropdown } from '../components'; import { Window } from '../layouts'; import { globalEvents } from '../events.js'; -import { createLogger } from '../logging'; const KEY_MODS = { 'SHIFT': true, @@ -34,10 +33,6 @@ export const KeyBinds = (props, context) => { ? getAllKeybinds(glob_keybinds) : glob_keybinds[selectedTab]; - const logger = createLogger('waa'); - - logger.warn(keybinds_to_use); - const filteredKeybinds = keybinds_to_use.filter((val) => val.full_name.toLowerCase().match(searchTerm) ); @@ -255,7 +250,7 @@ export class ButtonKeybind extends Component { let pressedKey = e.key.toUpperCase(); - this.finishTimerStart(200); + this.finishTimerStart(600); // Prevents repeating if (keysDown[pressedKey] && e.type === 'keydown') { @@ -284,6 +279,8 @@ export class ButtonKeybind extends Component { }); this.finishTimerStart(2000); globalEvents.on('keydown', this.preventPassthrough); + globalEvents.on('key', this.preventPassthrough); + globalEvents.on('keyup', this.preventPassthrough); } doBlur() { @@ -292,6 +289,8 @@ export class ButtonKeybind extends Component { keysDown: {}, }); globalEvents.off('keydown', this.preventPassthrough); + globalEvents.off('key', this.preventPassthrough); + globalEvents.off('keyup', this.preventPassthrough); } render() {