From 94dad5e089edac2fc2e4a7a16de02541cb4a409a Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 9 Sep 2026 12:59:37 -0400 Subject: [PATCH] fix(reader): stop page-turn and zoom shortcuts while typing in form fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handleKeydown computed a 'typing' guard for the event target but only applied it to the drawer-shortcut block (t/s/b/?//). The vi-style page turns (h/l), arrows, and zoom keys (+/−/0) fired regardless, so typing into the note textarea hijacked the keys: 'Wh' turned back a page on the h, arrows moved pages instead of the caret, and digits/minus zoomed. Return early for INPUT/SELECT/TEXTAREA/contentEditable targets, keeping Escape live so popovers and drawers stay dismissable from the keyboard mid-note. Covers the selection-popover note field, the notes drawer textarea, bookmark rename, and the search box. The now-unreachable '!typing' condition on the shortcut block is dropped. --- web/src/reader/reader.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/web/src/reader/reader.ts b/web/src/reader/reader.ts index 805e99b..2af8020 100644 --- a/web/src/reader/reader.ts +++ b/web/src/reader/reader.ts @@ -2493,11 +2493,18 @@ document.addEventListener("alpine:init", () => { }, handleKeydown(event: KeyboardEvent) { const k = event.key; - // Never hijack keys while the user is typing in a form control. - const tag = (event.target as HTMLElement)?.tagName; + // Never hijack keys while the user is typing in a form control: the + // field must receive h/l page turns, +/− zoom, and caret arrows. + // Escape stays live so popovers/drawers can still be dismissed from + // the keyboard even mid-note. + const t = event.target as HTMLElement | null; const typing = - tag === "INPUT" || tag === "SELECT" || tag === "TEXTAREA"; + t?.tagName === "INPUT" || + t?.tagName === "SELECT" || + t?.tagName === "TEXTAREA" || + !!t?.isContentEditable; this.pokeChrome(); + if (typing && k !== "Escape") return; if (k === "ArrowLeft" || k === "h") { if (event.altKey) { event.preventDefault(); @@ -2526,7 +2533,7 @@ document.addEventListener("alpine:init", () => { } else if (k === "F1") { event.preventDefault(); this.toggleHelp(); - } else if (!typing) { + } else { if (k === "t") this.toggleTOC(); else if (k === "s") this.toggleSettings(); else if (k === "b") this.addBookmark();