feat: Add support for handling chat input keydown events
This commit is contained in:
19
src/utils/key-down.tsx
Normal file
19
src/utils/key-down.tsx
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user