SimpleChat: textarea for multiline user chat, inturn shift+enter 4 enter

This commit is contained in:
HanishKVC 2024-05-20 11:56:41 +05:30
parent c88088c7a1
commit dfadac7813
2 changed files with 8 additions and 5 deletions

View file

@ -30,14 +30,15 @@
</div>
<hr>
<div id="chat">
<p> Enter the system prompt above, before entering/submitting any user query</p>
<p> Enter your text to the ai assistant below</p>
<p> Refresh the page to start over fresh</p>
<p> Enter the system prompt above, before entering/submitting any user query.</p>
<p> Enter your text to the ai assistant below.</p>
<p> Use shift+enter for inserting enter.</p>
<p> Refresh the page to start over fresh.</p>
</div>
<hr>
<div class="sameline">
<input type="text" id="user" class="flex-grow" />
<textarea id="user" class="flex-grow" rows="3"></textarea>
<button id="submit">submit</button>
</div>
</body>

View file

@ -239,7 +239,9 @@ function startme() {
});
inputUser?.addEventListener("keyup", (ev)=> {
if (ev.key === "Enter") {
// allow user to insert enter into their message using shift+enter.
// while just pressing enter key will lead to submitting.
if ((ev.key === "Enter") && (!ev.shiftKey)) {
btnSubmit?.click();
ev.preventDefault();
}