From d16bd22a8fca6a3716b2ac8b4de33a3549850e4d Mon Sep 17 00:00:00 2001 From: Vishesh Date: Thu, 17 Apr 2025 12:12:53 +0530 Subject: [PATCH] Reset modifier button's state when connection is completed --- systemvm/agent/noVNC/app/ui.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/systemvm/agent/noVNC/app/ui.js b/systemvm/agent/noVNC/app/ui.js index e99d763d60cf..b6fe6b036cb2 100644 --- a/systemvm/agent/noVNC/app/ui.js +++ b/systemvm/agent/noVNC/app/ui.js @@ -1147,6 +1147,7 @@ const UI = { msg = _("Connected (unencrypted) to ") + UI.desktopName; } UI.showStatus(msg); + UI.resetModifierKeysState(); UI.updateVisualState('connected'); // Do this last because it can only be used on rendered elements @@ -1783,6 +1784,35 @@ const UI = { selectbox.options.add(optn); }, + // Function to reset all modifier key states when reconnecting + resetModifierKeysState() { + // Reset the UI buttons for special keys + const modifierButtons = [ + 'noVNC_toggle_ctrl_button', + 'noVNC_toggle_shift_button', + 'noVNC_toggle_alt_button', + 'noVNC_toggle_windows_button' + ]; + + for (let id of modifierButtons) { + const btn = document.getElementById(id); + if (btn && btn.classList.contains("noVNC_selected")) { + btn.classList.remove("noVNC_selected"); + + // Also send the key-up event if needed + if (id === 'noVNC_toggle_ctrl_button') { + UI.sendKey(KeyTable.XK_Control_L, "ControlLeft", false); + } else if (id === 'noVNC_toggle_shift_button') { + UI.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", false); + } else if (id === 'noVNC_toggle_alt_button') { + UI.sendKey(KeyTable.XK_Alt_L, "AltLeft", false); + } else if (id === 'noVNC_toggle_windows_button') { + UI.sendKey(KeyTable.XK_Super_L, "MetaLeft", false); + } + } + } + }, + /* ------^------- * /MISC * ==============