Update SpeechRecognition.tsx

This commit is contained in:
bsu3338 2023-08-09 15:15:58 -05:00 committed by GitHub
parent 776daa1bc5
commit c02d43bd36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 };
};