╭ changed ──────────╮ │src/embed/script.js│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────╮ │87 overlay.innerHTML = html; │ │88 }, │ │89 _focusInput: function (id) { │ │90 - const target = overlay.querySelector(`input[data-focus-id="${id}"]`);│ │90 + const target = overlay.querySelector(`[data-focus-id="${id}"]`); │ │91 if (target && document.activeElement !== target) target.focus(); │ │92 }, │ │93 }, │ ╰─────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ │101 wasmInstance.exports._tick(minRows(), maxCols()); │ │102 } │ │103 │ │104 +function sendEnter(form) { │ │105 + const btn = form.querySelector("[data-focus-id]"); │ │106 + if (!btn) return; │ │107 + wasmInstance.exports._onMouseClick(Number(btn.dataset.focusId)); │ │108 + wasmInstance.exports._onKeyDown(13); │ │109 + wasmInstance.exports._tick(minRows(), maxCols()); │ │110 +} │ │111 + │ │112 WebAssembly.instantiateStreaming(fetch("haxy.wasm"), importObject).then(async (result) => {│ │113 wasmInstance = result.instance; │ │114 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────╮ │134 // the event so the TUI can move focus between widgets. │ │135 if (document.activeElement) { │ │136 const tag = document.activeElement.tagName; │ │137 + const isArrow = event.key === "ArrowUp" || event.key === "ArrowDown" || │ │138 + event.key === "ArrowLeft" || event.key === "ArrowRight"; │ │139 if (tag === "INPUT" && (event.key === "ArrowUp" || event.key === "ArrowDown")) {│ │140 + // up/down moves between widgets; left/right stay in the input │ │141 + document.activeElement.blur(); │ │142 + } else if (tag === "BUTTON" && isArrow) { │ │143 + // arrows navigate away from a focused submit button │ │144 document.activeElement.blur(); │ │145 } else if (tag === "INPUT" || tag === "BUTTON") { │ │146 + // Enter (submit), typing, Tab — handled natively by the browser │ │147 return; │ │148 } │ │149 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯