mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-25 00:16:29 +02:00
enter to submit
This commit is contained in:
parent
3a0bb3ed3b
commit
c35db60736
1 changed files with 16 additions and 0 deletions
|
|
@ -765,6 +765,22 @@ function App() {
|
||||||
isRecordingRef.current = false
|
isRecordingRef.current = false
|
||||||
}, [voice])
|
}, [voice])
|
||||||
|
|
||||||
|
// Enter to submit voice input, Escape to cancel
|
||||||
|
useEffect(() => {
|
||||||
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
|
if (!isRecordingRef.current) return
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
e.preventDefault()
|
||||||
|
handleSubmitRecording()
|
||||||
|
} else if (e.key === 'Escape') {
|
||||||
|
e.preventDefault()
|
||||||
|
handleCancelRecording()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.addEventListener('keydown', handleKeyDown)
|
||||||
|
return () => document.removeEventListener('keydown', handleKeyDown)
|
||||||
|
}, [handleSubmitRecording, handleCancelRecording])
|
||||||
|
|
||||||
// Helper to cancel recording from any navigation handler
|
// Helper to cancel recording from any navigation handler
|
||||||
const cancelRecordingIfActive = useCallback(() => {
|
const cancelRecordingIfActive = useCallback(() => {
|
||||||
if (isRecordingRef.current) {
|
if (isRecordingRef.current) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue