From c02d43bd367efec43dc60401d40cd121866610b5 Mon Sep 17 00:00:00 2001 From: bsu3338 Date: Wed, 9 Aug 2023 15:15:58 -0500 Subject: [PATCH] Update SpeechRecognition.tsx --- .../src/components/Input/SpeechRecognition.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/src/components/Input/SpeechRecognition.tsx b/client/src/components/Input/SpeechRecognition.tsx index 26cfec7dc4..d232bf5f91 100644 --- a/client/src/components/Input/SpeechRecognition.tsx +++ b/client/src/components/Input/SpeechRecognition.tsx @@ -65,6 +65,22 @@ const useSpeechRecognition = (ask) => { } }; + const handleKeyDown = (event) => { + if (e.shiftKey && e.altKey && e.key === 'L') { + if (isSpeechSupported) { + toggleListening(); + } + } + }; + + useEffect(() => { + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; + }, [isListening]); + return { isSpeechSupported, isListening, text, toggleListening }; };