Skip to content

Commit

Permalink
Send message on enter instead of shift enter
Browse files Browse the repository at this point in the history
  • Loading branch information
cephalization committed Oct 29, 2023
1 parent 20df31b commit 830da33
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@
authorId === data.user.id ? 'text-info' : 'text-base-content';
function textareaKeyDown(e: KeyboardEvent) {
if (!e.key || (!e.metaKey && !e.shiftKey)) {
// skip handleSubmit if enter + cmd or enter + shift is pressed
if (e.key === 'Enter' && (e.metaKey || e.shiftKey)) {
return;
}
// call handleSubmit if enter + cmd or enter + shift is pressed
if (e.key === 'Enter' && (e.metaKey || e.shiftKey)) {
e.preventDefault();
document.getElementById('send-btn')?.click();
}
e.preventDefault();
document.getElementById('send-btn')?.click();
}
async function handleSubmit(event: { currentTarget: EventTarget & HTMLFormElement }) {
Expand Down Expand Up @@ -203,7 +201,7 @@
on:keydown={textareaKeyDown}
use:autosize
name="content"
placeholder="Shift + Enter to send a message. Enter to add a new line."
placeholder="Shift + Enter to add a new line. Enter to send."
style="overflow-x: hidden;"
class="input input-bordered w-full join-item max-h-36 !overflow-x-hidden resize-none pt-3"
/>
Expand Down

0 comments on commit 830da33

Please sign in to comment.