fix: Fixed keyboard disconnect
Server Deploy / deploy (push) Successful in 41s

This commit is contained in:
2026-07-20 09:42:07 +01:00
parent 963fa9c877
commit c558b81471
+11 -1
View File
@@ -14,6 +14,8 @@ export function openConsole(
container.innerHTML = "";
container.appendChild(client.getDisplay().getElement());
// Make the console focusable so keyboard capture is scoped to it (see below).
container.tabIndex = 0;
client.connect(connectData);
@@ -37,12 +39,20 @@ export function openConsole(
);
client.sendMouseState(s);
};
const keyboard = new Guacamole.Keyboard(document);
// Scope keyboard capture to the container rather than `document`, so it only
// grabs keys while the console is focused and stops entirely once the element
// is removed (navigating away / disconnect). Attaching to `document` leaks the
// capture and swallows keystrokes in unrelated inputs.
const keyboard = new Guacamole.Keyboard(container);
keyboard.onkeydown = (k: number) => client.sendKeyEvent(1, k);
keyboard.onkeyup = (k: number) => client.sendKeyEvent(0, k);
container.focus();
return {
disconnect() {
keyboard.onkeydown = null;
keyboard.onkeyup = null;
if (typeof keyboard.reset === "function") keyboard.reset();
client.disconnect();
},
setScale(s: number) {