diff --git a/static/index.html b/static/index.html index 9b0e69b..2d06479 100644 --- a/static/index.html +++ b/static/index.html @@ -15,7 +15,7 @@
- +
diff --git a/static/script.js b/static/script.js index bcf98d0..72221c7 100644 --- a/static/script.js +++ b/static/script.js @@ -13,10 +13,18 @@ sendButton.addEventListener("click", () => { ); -promptInput.addEventListener("keyup", () => { - handleKeyPress(event); -} -); +promptInput.addEventListener("input", () => { + if (promptInput.value.split("\n").length == 1) { + promptInput.style.height = "2.5rem"; + } else { + promptInput.style.height = ""; + promptInput.style.height = promptInput.scrollHeight + "px"; + } +}); + +promptInput.addEventListener("keypress", () => { + handleKeyPress(event); +}); async function sendMessage() { @@ -99,7 +107,8 @@ function hideTypingIndicator() { } function handleKeyPress(event) { - if (event.key === "Enter") { + if (event.key == "Enter" && !event.shiftKey) { + event.preventDefault(); sendMessage(); } }