fix: clear sticky mobile modifiers for iPad keyboards

Remove debug logging, ensure modifiers clear after input events, and clear
keybar modifier state when physical keyboard input occurs outside the
mobile textarea. This prevents Ctrl/Shift from remaining stuck on iPad
hardware keyboards.
This commit is contained in:
GitHub Copilot
2026-01-29 22:50:32 +00:00
parent 2269eada42
commit 322b82dc79
2 changed files with 19 additions and 8 deletions
File diff suppressed because one or more lines are too long
+14 -3
View File
@@ -674,7 +674,6 @@ class WebTerminal {
// Handle input from mobile keyboard (regular text only, special keys handled above)
textarea.addEventListener("input", () => {
const value = textarea.value;
console.log("[webterm:mobile] input event fired, value:", value, "ctrlActive:", this.ctrlActive, "shiftActive:", this.shiftActive);
if (value) {
let toSend = value;
// Apply Shift modifier (uppercase letters)
@@ -688,7 +687,6 @@ class WebTerminal {
toSend = String.fromCharCode(code - 64); // Ctrl+A = 0x01, Ctrl+D = 0x04, etc.
}
}
console.log("[webterm:mobile] sending:", toSend.charCodeAt(0), "calling deactivateModifiers");
this.send(["stdin", toSend]);
textarea.value = "";
this.deactivateModifiers();
@@ -750,6 +748,20 @@ class WebTerminal {
}
});
// Clear keybar modifiers when physical keyboard input occurs outside the textarea.
document.addEventListener("keydown", (event) => {
if (!this.ctrlActive && !this.shiftActive) {
return;
}
if (event.target === this.mobileInput) {
return;
}
if (["Shift", "Control", "Alt", "Meta"].includes(event.key)) {
return;
}
this.deactivateModifiers();
});
// Focus textarea on touch/click to show mobile keyboard
// iOS requires focus() to be called synchronously within the gesture
// Don't call terminal.focus() as it steals focus and dismisses keyboard
@@ -948,7 +960,6 @@ class WebTerminal {
/** Deactivate all modifiers */
private deactivateModifiers(): void {
console.log("[webterm:mobile] deactivateModifiers called");
this.ctrlActive = false;
this.shiftActive = false;
this.mobileKeybar?.querySelectorAll("button[data-modifier]").forEach((btn) => {