Skip to content

Commit

Permalink
Fix refreshing when focused
Browse files Browse the repository at this point in the history
  • Loading branch information
Drulikar committed Aug 17, 2023
1 parent 9041db4 commit e6ea04a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tgui/packages/tgui/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions tgui/packages/tgui/interfaces/KeyBinds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down

0 comments on commit e6ea04a

Please sign in to comment.