From e6ea04aa0cf7ff8f71d426885f5ea6c0b1e931c6 Mon Sep 17 00:00:00 2001 From: Drulikar Date: Thu, 17 Aug 2023 02:38:43 -0700 Subject: [PATCH] Fix refreshing when focused --- tgui/packages/tgui/hotkeys.ts | 5 ++++- tgui/packages/tgui/interfaces/KeyBinds.js | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 0325ead1058c..5bdecf871c6b 100644 --- a/tgui/packages/tgui/interfaces/KeyBinds.js +++ b/tgui/packages/tgui/interfaces/KeyBinds.js @@ -279,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() { @@ -287,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() {