Capture Cmd+D dictation on web

This commit is contained in:
Mohamed Boudra
2025-11-23 14:36:01 +01:00
parent 6aa9b1c72e
commit 3b20cf0654
@@ -463,14 +463,20 @@ export function AgentInputArea({ agentId }: AgentInputAreaProps) {
return; return;
} }
const handleDictationShortcut = (event: KeyboardEvent) => { const listener = (event: KeyboardEvent) => {
const key = event.key.toLowerCase(); const key = event.key.toLowerCase();
const isCommandLike = event.metaKey || event.ctrlKey;
if (event.metaKey && !event.altKey && !event.ctrlKey && key === "d") { if (isCommandLike && !event.altKey && key === "d") {
event.preventDefault(); event.preventDefault();
event.stopPropagation();
if (isRecording) { if (isRecording) {
void handleSendRecording(); void handleSendRecording();
} else if (!isRealtimeMode && shouldShowVoiceControls && ws.isConnected) { return;
}
if (!isRealtimeMode && shouldShowVoiceControls && ws.isConnected) {
void handleVoicePress(); void handleVoicePress();
} }
return; return;
@@ -478,13 +484,14 @@ export function AgentInputArea({ agentId }: AgentInputAreaProps) {
if (key === "escape" && isRecording) { if (key === "escape" && isRecording) {
event.preventDefault(); event.preventDefault();
event.stopPropagation();
void handleCancelRecording(); void handleCancelRecording();
} }
}; };
window.addEventListener("keydown", handleDictationShortcut); window.addEventListener("keydown", listener, true);
return () => { return () => {
window.removeEventListener("keydown", handleDictationShortcut); window.removeEventListener("keydown", listener, true);
}; };
}, [ }, [
isRecording, isRecording,