Skip to content

Commit

Permalink
Prevent F5 reload
Browse files Browse the repository at this point in the history
  • Loading branch information
S34NW authored and AyIong committed Jan 19, 2024
1 parent 0235560 commit b8230a7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tgui/packages/tgui/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const hotKeysAcquired = [
keycodes.KEY_DOWN,
keycodes.KEY_LEFT,
keycodes.KEY_RIGHT,
keycodes.KEY_F5,
];

// State of passed-through keys.
Expand Down Expand Up @@ -68,7 +67,7 @@ const keyCodeToByond = (keyCode: number) => {
*/
const handlePassthrough = (key: KeyEvent) => {
const keyString = String(key);
// In addition to F5, support reloading with Ctrl+R and Ctrl+F5
// Support reloading with Ctrl+R and Ctrl+F5
if (keyString === 'Ctrl+F5' || keyString === 'Ctrl+R') {
location.reload();
return;
Expand All @@ -85,6 +84,11 @@ const handlePassthrough = (key: KeyEvent) => {
) {
return;
}
if (keyString === 'F5') {
// Hacky prevention of F5 reloading
key.event.preventDefault();
key.event.returnValue = false;
}
const byondKeyCode = keyCodeToByond(key.code);
if (!byondKeyCode) {
return;
Expand Down

0 comments on commit b8230a7

Please sign in to comment.