submit messages on enter

This commit is contained in:
Gabriel mermelstein 2024-06-12 17:38:52 +02:00
parent 97f1ae78ff
commit 4a6d3bfe09
No known key found for this signature in database
GPG Key ID: 82B8134785FEAE0D

View File

@ -212,6 +212,13 @@ function App() {
} }
}; };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const checkForEnter = (e: any) => {
if (e.key === 'Enter') {
sendMessage()
}
}
const createUser = async () => { const createUser = async () => {
try { try {
const name = await CreateUser(usernameInput); const name = await CreateUser(usernameInput);
@ -456,6 +463,7 @@ function App() {
<Input <Input
value={newMessage} value={newMessage}
onChange={updateMessage} onChange={updateMessage}
onKeyDown={checkForEnter}
placeholder="Input your message" placeholder="Input your message"
autoComplete="off" autoComplete="off"
autoCorrect="off" autoCorrect="off"