╭ changed ──────────╮ │src/embed/script.js│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────╮ │189 // let the browser handle modifier combos. the TUI only uses unmodified keys,│ │190 // so intercepting these would just break normal browser navigation. │ │191 if (event.altKey || event.ctrlKey || event.metaKey) return; │ │192 - // when a form element (text input or submit button) owns focus, │ │193 - // the browser handles typing, Enter-to-submit, and Tab natively. │ │194 - // we only forward keys into the TUI when focus is elsewhere. │ │192 + // when a form element (text input or submit button) owns focus, the │ │193 + // browser handles typing and Tab natively (and Enter on the button │ │194 + // submits). we only forward keys into the TUI when focus is elsewhere. │ │195 // exception: arrow up/down on an input unfocuses it and forwards │ │196 // the event so the TUI can move focus between widgets. │ │197 if (document.activeElement) { │ ╰──────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────╮ │198 const tag = document.activeElement.tagName; │ │199 const isArrow = event.key === "ArrowUp" || event.key === "ArrowDown" || │ │200 event.key === "ArrowLeft" || event.key === "ArrowRight"; │ │201 + if (tag === "INPUT" && event.key === "Enter") { │ │202 + // enter in a text input never submits the form; only the │ │203 + // submit button does │ │204 + event.preventDefault(); │ │205 + return; │ │206 + } │ │207 if (tag === "INPUT" && (event.key === "ArrowUp" || event.key === "ArrowDown")) {│ │208 // up/down moves between widgets; left/right stay in the input │ │209 document.activeElement.blur(); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────╮ │210 } else if (tag === "BUTTON" && isArrow) { │ │211 // arrows navigate away from a focused submit button │ │212 document.activeElement.blur(); │ │207 - } else if (tag === "INPUT" || tag === "BUTTON") { │ │208 - // Enter (submit), typing, Tab — handled natively by the browser │ │213 + } else if (tag === "INPUT" || tag === "BUTTON" || tag === "TEXTAREA") {│ │214 + // Enter (submit / newline), typing, Tab, and a textarea's │ │215 + // arrows — handled natively by the browser │ │216 return; │ │217 } │ │218 } │ ╰────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │227 // input/focus events from form elements still bubble up to document. │ │228 document.addEventListener("input", (event) => { │ │229 const t = event.target; │ │223 - if (!t || t.tagName !== "INPUT" || !t.dataset.focusId) return; │ │230 + if (!t || (t.tagName !== "INPUT" && t.tagName !== "TEXTAREA") || !t.dataset.focusId) return;│ │231 sendTextInputValue(Number(t.dataset.focusId), t.value); │ │232 }); │ │233 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯