From 2e2dd9849d0df7c2e6443ffc71b12662de26d688 Mon Sep 17 00:00:00 2001 From: catborise Date: Tue, 27 Oct 2026 08:41:14 +0300 Subject: [PATCH] fix(console): a held key let go on the keyboard is let go in the VM A key held from the menu (Hold Ctrl, Alt or Windows) is the same key as the keyboard's left Ctrl, Alt or Windows key. Pressing and releasing that key on the screen let the VM's key go, while the menu still showed it held. And when the key went down outside the screen (in the Clipboard dialog) and came up on it, noVNC sent no release, as it had not seen the key go down. The release of that key where noVNC takes keys (the screen, the touch keyboard) now lets a held key go itself, and clears the menu's mark. A release elsewhere reaches no VM and changes nothing. --- static/js/console_keys.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/static/js/console_keys.js b/static/js/console_keys.js index d931128a..570adc9b 100644 --- a/static/js/console_keys.js +++ b/static/js/console_keys.js @@ -69,6 +69,19 @@ export function bindSendKeys(rfb) { } }); } + // the same key on the keyboard, where noVNC takes keys (the screen, the + // touch keyboard): its release lets the held key go. Sent here, seen + // before noVNC (which keeps the event to itself): noVNC sends no release + // of a key it did not see go down, as when it went down in a dialog. + for (const target of [document.getElementById('screen'), document.getElementById('keyboard_input')]) { + target.addEventListener('keyup', (e) => { + for (const [id, key] of HOLDS) { + if (e.code === key.code && document.getElementById(id).getAttribute('aria-pressed') === 'true') { + hold(rfb, id, key, false); + } + } + }, true); + } } // the Fullscreen item; in full screen the page also takes the keys the