Skip to content

covers a few more stickykey cases #8712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tgui/packages/tgui/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import { createAction } from 'common/redux';
import { setupDrag } from './drag';
import { globalEvents } from './events';
import { focusMap } from './focus';
import {
releaseHeldKeys,
startKeyPassthrough,
stopKeyPassthrough,
} from './hotkeys';
import { createLogger } from './logging';
import { resumeRenderer, suspendRenderer } from './renderer';

Expand Down Expand Up @@ -177,6 +182,8 @@ export const backendMiddleware = (store) => {
Byond.winset(Byond.windowId, {
'is-visible': false,
});
stopKeyPassthrough();
releaseHeldKeys();
setTimeout(() => focusMap());
}

Expand All @@ -203,6 +210,7 @@ export const backendMiddleware = (store) => {
logger.log('backend/update', payload);
// Signal renderer that we have resumed
resumeRenderer();
startKeyPassthrough();
// Setup drag
setupDrag(payload.config?.window?.fancy);
// We schedule this for the next tick here because resizing and unhiding
Expand Down
22 changes: 16 additions & 6 deletions tgui/packages/tgui/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,22 @@ export const setupHotKeys = () => {
globalEvents.on('window-blur', () => {
releaseHeldKeys();
});
globalEvents.on('key', (key: KeyEvent) => {
for (const keyListener of keyListeners) {
keyListener(key);
}
handlePassthrough(key);
});
startKeyPassthrough();
};

export const startKeyPassthrough = () => {
globalEvents.on('key', keyEvent);
};

export const stopKeyPassthrough = () => {
globalEvents.off('key', keyEvent);
};

const keyEvent = (key: KeyEvent) => {
for (const keyListener of keyListeners) {
keyListener(key);
}
handlePassthrough(key);
};

/**
Expand Down