feat: Add support for handling chat input keydown events

This commit is contained in:
n4ze3m
2024-08-20 20:22:01 +05:30
parent 35b8579028
commit 9679f92821
4 changed files with 57 additions and 16 deletions

19
src/utils/key-down.tsx Normal file
View File

@@ -0,0 +1,19 @@
export const handleChatInputKeyDown = ({
e,
sendWhenEnter,
typing,
isSending
}: {
e: React.KeyboardEvent
typing: boolean
sendWhenEnter: boolean
isSending: boolean
}) => {
return import.meta.env.BROWSER === "firefox"
? e.key === "Enter" &&
!e.shiftKey &&
!e.nativeEvent.isComposing &&
!isSending &&
sendWhenEnter
: !typing && e.key === "Enter" && !e.shiftKey && !isSending && sendWhenEnter
}