diff --git a/src/pages/qa.ts b/src/pages/qa.ts index 190b4ca..4c675b6 100644 --- a/src/pages/qa.ts +++ b/src/pages/qa.ts @@ -38,6 +38,13 @@ export async function qaPage(outlet: HTMLElement) { charCount.textContent = `${input.value.length}/200`; }); + input.addEventListener("keydown", (e) => { + if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault(); + form.requestSubmit(); + } + }); + form.addEventListener("submit", (e) => { e.preventDefault(); const question = input.value.trim(); @@ -50,11 +57,13 @@ export async function qaPage(outlet: HTMLElement) { .then(() => { input.value = ""; charCount.textContent = "0/200"; - status.textContent = "Question submitted! It will appear here once answered."; + status.textContent = + "Question submitted! It will appear here once answered."; status.style.color = "var(--light-green)"; }) .catch((err: unknown) => { - status.textContent = err instanceof Error ? err.message : "Failed to submit question."; + status.textContent = + err instanceof Error ? err.message : "Failed to submit question."; status.style.color = "var(--light-red)"; }); });