From 84eaad8029aef9478d3c5264a432ff9ffe04267d Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 19 Dec 2025 21:08:24 +0100 Subject: [PATCH] fix(tui): use isBackspace and isEnter helpers in Editor Fixes Backspace and Enter not working with Caps Lock enabled. The Kitty protocol sends lock key bits in modifiers which broke the raw byte detection. --- packages/tui/src/components/editor.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/tui/src/components/editor.ts b/packages/tui/src/components/editor.ts index 452fd308..2c7e5b1f 100644 --- a/packages/tui/src/components/editor.ts +++ b/packages/tui/src/components/editor.ts @@ -8,6 +8,7 @@ import { isArrowLeft, isArrowRight, isArrowUp, + isBackspace, isCtrlA, isCtrlC, isCtrlE, @@ -421,8 +422,8 @@ export class Editor implements Component { // Modifier + Enter = new line this.addNewLine(); } - // Plain Enter (char code 13 for CR) - only CR submits, LF adds new line - else if (data.charCodeAt(0) === 13 && data.length === 1) { + // Plain Enter - submit (handles both legacy \r and Kitty protocol with lock bits) + else if (isEnter(data)) { // If submit is disabled, do nothing if (this.disableSubmit) { return; @@ -458,7 +459,7 @@ export class Editor implements Component { } } // Backspace - else if (data.charCodeAt(0) === 127 || data.charCodeAt(0) === 8) { + else if (isBackspace(data)) { this.handleBackspace(); } // Line navigation shortcuts (Home/End keys)