Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat: add cancel recording hotkey (Escape by default, configurable)

Noam71afd2973dd9
diff --git a/preload.js b/preload.js
index ee3b157d4..081c91f2f 100644
--- a/preload.js
+++ b/preload.js
@@ -264,6 +264,9 @@ contextBridge.exposeInMainWorld("electronAPI", {
// Audio event listeners
onNoAudioDetected: registerListener("no-audio-detected"),
+ onCancelHotkeyPressed: registerListener("cancel-hotkey-pressed", (cb) => () => cb()),
+ registerCancelHotkey: (key) => ipcRenderer.invoke("register-cancel-hotkey", key),
+ unregisterCancelHotkey: () => ipcRenderer.invoke("unregister-cancel-hotkey"),
// External link opener
openExternal: (url) => ipcRenderer.invoke("open-external", url),
diff --git a/src/App.jsx b/src/App.jsx
index f8bf7db04..807eb8ab9 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -195,6 +195,13 @@ export default function App() {
return () => unsubscribe?.();
}, []);
+ useEffect(() => {
+ const unsubscribe = window.electronAPI?.onCancelHotkeyPressed?.(() => {
+ if (isRecording) cancelRecording();
+ });
+ return () => unsubscribe?.();
+ }, [isRecording, cancelRecording]);
+
// Auto-hide the floating icon when idle (setting enabled or dictation cycle completed)
useEffect(() => {
let hideTimeout;
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index 12716f166..73152be23 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -654,6 +654,7 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
groqApiKey,
mistralApiKey,
dictationKey,
+ cancelKey,
activationMode,
setActivationMode,
preferBuiltInMic,
@@ -682,6 +683,7 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
customReasoningApiKey,
setCustomReasoningApiKey,
setDictationKey,
+ setCancelKey,
autoLearnCorrections,
setAutoLearnCorrections,
updateTranscriptionSettings,
@@ -2415,6 +2417,29 @@ EOF`,
)}
</SettingsPanelRow>
+ {/* Cancel Hotkey */}
+ <SettingsPanelRow>
+ <p className="text-xs font-medium text-muted-foreground/80 mb-2">
+ {t("settingsPage.general.hotkey.cancelTitle")}
+ </p>
+ <p className="text-xs text-muted-foreground/60 mb-2">
+ {t("settingsPage.general.hotkey.cancelDescription")}
+ </p>
+ <HotkeyInput
+ value={cancelKey}
+ onChange={(newKey) => setCancelKey(newKey)}
+ skipListeningMode
+ />
+ {cancelKey && cancelKey !== "Escape" && (
+ <button
+ onClick={() => setCancelKey("Escape")}
+ className="mt-2 text-xs text-muted-foreground/70 hover:text-foreground transition-colors"
+ >
+ {t("settingsPage.general.hotkey.resetToDefault", { hotkey: "Escape" })}
+ </button>
+ )}
+ </SettingsPanelRow>
+
{!isUsingGnomeHotkeys && (
<SettingsPanelRow>
<p className="text-xs font-medium text-muted-foreground/80 mb-2">
diff --git a/src/components/ui/HotkeyInput.tsx b/src/components/ui/HotkeyInput.tsx
index d6df8c5ec..cc7f76fb8 100644
--- a/src/components/ui/HotkeyInput.tsx
+++ b/src/components/ui/HotkeyInput.tsx
@@ -147,6 +147,7 @@ export interface HotkeyInputProps {
disabled?: boolean;
autoFocus?: boolean;
validate?: (hotkey: string) => string | null | undefined;
+ skipListeningMode?: boolean;
}
export function mapKeyboardEventToHotkey(e: KeyboardEvent): string | null {
@@ -188,6 +189,7 @@ export function HotkeyInput({
autoFocus = false,
variant = "default",
validate,
+ skipListeningMode = false,
}: HotkeyInputProps & HotkeyInputVariant) {
const { t } = useTranslation();
const [isCapturing, setIsCapturing] = useState(false);
@@ -401,19 +403,20 @@ export function HotkeyInput({
setIsCapturing(true);
setValidationWarning(null);
clearFnHeld();
- window.electronAPI?.setHotkeyListeningMode?.(true);
+ if (!skipListeningMode) window.electronAPI?.setHotkeyListeningMode?.(true);
}
- }, [disabled, clearFnHeld]);
+ }, [disabled, clearFnHeld, skipListeningMode]);
const handleBlur = useCallback(() => {
setIsCapturing(false);
setActiveModifiers(new Set());
setValidationWarning(null);
clearFnHeld();
- window.electronAPI?.setHotkeyListeningMode?.(false, lastCapturedHotkeyRef.current);
+ if (!skipListeningMode)
+ window.electronAPI?.setHotkeyListeningMode?.(false, lastCapturedHotkeyRef.current);
lastCapturedHotkeyRef.current = null;
onBlur?.();
- }, [onBlur, clearFnHeld]);
+ }, [onBlur, clearFnHeld, skipListeningMode]);
useEffect(() => {
if (autoFocus && containerRef.current) {
@@ -423,10 +426,10 @@ export function HotkeyInput({
useEffect(() => {
return () => {
- window.electronAPI?.setHotkeyListeningMode?.(false, null);
+ if (!skipListeningMode) window.electronAPI?.setHotkeyListeningMode?.(false, null);
if (warningTimeoutRef.current) clearTimeout(warningTimeoutRef.current);
};
- }, []);
+ }, [skipListeningMode]);
useEffect(() => {
if (!isCapturing || !isMac) return;
@@ -466,6 +469,7 @@ export function HotkeyInput({
tabIndex={disabled ? -1 : 0}
role="button"
aria-label={t("hotkeyInput.ariaLabel")}
+ data-capturing={isCapturing || undefined}
onKeyDown={handleKeyDown}
onKeyUp={handleKeyUp}
onFocus={handleFocus}
@@ -569,6 +573,7 @@ export function HotkeyInput({
tabIndex={disabled ? -1 : 0}
role="button"
aria-label={t("hotkeyInput.ariaLabel")}
+ data-capturing={isCapturing || undefined}
onKeyDown={handleKeyDown}
onKeyUp={handleKeyUp}
onFocus={handleFocus}
diff --git a/src/components/ui/SidebarModal.tsx b/src/components/ui/SidebarModal.tsx
index 62470acd3..ae7852855 100644
--- a/src/components/ui/SidebarModal.tsx
+++ b/src/components/ui/SidebarModal.tsx
@@ -82,7 +82,11 @@ export default function SidebarModal<T extends string>({
<DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>
<DialogPrimitive.Portal>
<DialogPrimitive.Overlay className="fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />
- <DialogPrimitive.Content className="fixed left-[50%] top-[50%] z-50 max-h-[85vh] w-[90vw] max-w-4xl translate-x-[-50%] translate-y-[-50%] rounded-xl p-0 overflow-hidden bg-background border border-border shadow-[0_25px_50px_-12px_rgba(0,0,0,0.25)] dark:bg-surface-1 dark:border-border-subtle dark:shadow-[0_25px_60px_-12px_rgba(0,0,0,0.5),0_0_0_1px_rgba(255,255,255,0.05)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98">
+ <DialogPrimitive.Content
+ onEscapeKeyDown={(e) => {
+ if (document.querySelector("[data-capturing]")) e.preventDefault();
+ }}
+ className="fixed left-[50%] top-[50%] z-50 max-h-[85vh] w-[90vw] max-w-4xl translate-x-[-50%] translate-y-[-50%] rounded-xl p-0 overflow-hidden bg-background border border-border shadow-[0_25px_50px_-12px_rgba(0,0,0,0.25)] dark:bg-surface-1 dark:border-border-subtle dark:shadow-[0_25px_60px_-12px_rgba(0,0,0,0.5),0_0_0_1px_rgba(255,255,255,0.05)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98">
<div className="relative h-full max-h-[85vh] overflow-hidden">
<DialogPrimitive.Close className="absolute right-4 top-4 z-10 rounded-md p-1.5 opacity-40 ring-offset-background transition-[opacity,background-color] hover:opacity-100 bg-transparent hover:bg-muted dark:hover:bg-surface-raised focus:outline-none focus:ring-2 focus:ring-ring/30 focus:ring-offset-1">
<X className="h-3.5 w-3.5 text-muted-foreground" />
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 53f3d571a..d7d6cd87e 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -1242,6 +1242,19 @@ class IPCHandlers {
};
});
+ ipcMain.handle("register-cancel-hotkey", async (event, key) => {
+ const hotkeyManager = this.windowManager.hotkeyManager;
+ const mainWindow = this.windowManager.mainWindow;
+ return hotkeyManager.registerSlot("cancel", key, () => {
+ mainWindow?.webContents?.send("cancel-hotkey-pressed");
+ });
+ });
+
+ ipcMain.handle("unregister-cancel-hotkey", async () => {
+ this.windowManager.hotkeyManager.unregisterSlot("cancel");
+ return { success: true };
+ });
+
ipcMain.handle("start-window-drag", async (event) => {
return await this.windowManager.startWindowDrag();
});
diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.js
index a3561cbec..8b7ed5ee0 100644
--- a/src/hooks/useAudioRecording.js
+++ b/src/hooks/useAudioRecording.js
@@ -36,6 +36,7 @@ export const useAudioRecording = (toast, options = {}) => {
if (getSettings().pauseMediaOnDictation) {
window.electronAPI?.pauseMediaPlayback?.();
}
+ window.electronAPI?.registerCancelHotkey?.(getSettings().cancelKey || "Escape");
}
return didStart;
@@ -53,6 +54,8 @@ export const useAudioRecording = (toast, options = {}) => {
const currentState = audioManagerRef.current.getState();
if (!currentState.isRecording && !currentState.isStreamingStartInProgress) return false;
+ window.electronAPI?.unregisterCancelHotkey?.();
+
if (currentState.isStreaming || currentState.isStreamingStartInProgress) {
void playStopCue();
return await audioManagerRef.current.stopStreamingRecording();
@@ -75,6 +78,7 @@ export const useAudioRecording = (toast, options = {}) => {
audioManagerRef.current.setCallbacks({
onStateChange: ({ isRecording, isProcessing, isStreaming }) => {
+ if (!isRecording) window.electronAPI?.unregisterCancelHotkey?.();
setIsRecording(isRecording);
setIsProcessing(isProcessing);
setIsStreaming(isStreaming ?? false);
@@ -233,6 +237,7 @@ export const useAudioRecording = (toast, options = {}) => {
const cancelRecording = async () => {
if (audioManagerRef.current) {
+ window.electronAPI?.unregisterCancelHotkey?.();
const state = audioManagerRef.current.getState();
if (getSettings().pauseMediaOnDictation) {
window.electronAPI?.resumeMediaPlayback?.();
diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.ts
index 56d0c62f4..b077a32f6 100644
--- a/src/hooks/useSettings.ts
+++ b/src/hooks/useSettings.ts
@@ -32,6 +32,7 @@ export interface ReasoningSettings {
export interface HotkeySettings {
dictationKey: string;
+ cancelKey: string;
activationMode: "tap" | "push";
}
@@ -188,6 +189,7 @@ function useSettingsInternal() {
groqApiKey: store.groqApiKey,
mistralApiKey: store.mistralApiKey,
dictationKey: store.dictationKey,
+ cancelKey: store.cancelKey,
theme: store.theme,
setUseLocalWhisper: store.setUseLocalWhisper,
setWhisperModel: store.setWhisperModel,
@@ -218,6 +220,7 @@ function useSettingsInternal() {
customReasoningApiKey: store.customReasoningApiKey,
setCustomReasoningApiKey: store.setCustomReasoningApiKey,
setDictationKey: store.setDictationKey,
+ setCancelKey: store.setCancelKey,
setTheme: store.setTheme,
activationMode: store.activationMode,
setActivationMode: store.setActivationMode,
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 5f4efca55..8d38bcbf4 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -1080,7 +1080,9 @@
"activationMode": "Aktivierungsmodus",
"description": "Die Tastenkombination, die das Sprachdiktat startet und stoppt",
"resetToDefault": "Auf {{hotkey}} zurücksetzen",
- "title": "Diktat-Hotkey"
+ "title": "Diktat-Hotkey",
+ "cancelTitle": "Abbrechen-Taste",
+ "cancelDescription": "Taste zum Abbrechen einer laufenden Aufnahme"
},
"microphone": {
"description": "Wählen Sie das Eingabegerät für das Diktat",
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 78c977de8..60c74680e 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -1143,7 +1143,9 @@
"activationMode": "Activation Mode",
"description": "The key combination that starts and stops voice dictation",
"resetToDefault": "Reset to {{hotkey}}",
- "title": "Dictation Hotkey"
+ "title": "Dictation Hotkey",
+ "cancelTitle": "Cancel Hotkey",
+ "cancelDescription": "Key to cancel an in-progress recording"
},
"microphone": {
"description": "Select which input device to use for dictation",
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 55785ec43..daa18a318 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -1084,7 +1084,9 @@
"activationMode": "Modo de activación",
"description": "La combinación de teclas que inicia y detiene el dictado por voz",
"resetToDefault": "Restablecer a {{hotkey}}",
- "title": "Atajo de dictado"
+ "title": "Atajo de dictado",
+ "cancelTitle": "Atajo de cancelación",
+ "cancelDescription": "Tecla para cancelar una grabación en curso"
},
"microphone": {
"description": "Selecciona qué dispositivo de entrada usar para dictado",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 1e5617ab2..590216e1f 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -1084,7 +1084,9 @@
"activationMode": "Mode d'activation",
"description": "La combinaison de touches qui démarre et arrête la dictée vocale",
"resetToDefault": "Réinitialiser à {{hotkey}}",
- "title": "Raccourci de dictée"
+ "title": "Raccourci de dictée",
+ "cancelTitle": "Raccourci d'annulation",
+ "cancelDescription": "Touche pour annuler un enregistrement en cours"
},
"microphone": {
"description": "Sélectionnez le périphérique d'entrée à utiliser pour la dictée",
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index b748525ca..fe92c1874 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -1084,7 +1084,9 @@
"activationMode": "Modalità di attivazione",
"description": "La combinazione di tasti che avvia e ferma la dettatura vocale",
"resetToDefault": "Ripristina a {{hotkey}}",
- "title": "Scorciatoia di dettatura"
+ "title": "Scorciatoia di dettatura",
+ "cancelTitle": "Tasto di annullamento",
+ "cancelDescription": "Tasto per annullare una registrazione in corso"
},
"microphone": {
"description": "Seleziona il dispositivo di ingresso da usare per la dettatura",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 9bdad1099..fc79fff2e 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -1080,7 +1080,9 @@
"activationMode": "起動モード",
"description": "音声ディクテーションの開始/停止に使用するキーの組み合わせ",
"resetToDefault": "{{hotkey}}にリセット",
- "title": "ディクテーションホットキー"
+ "title": "ディクテーションホットキー",
+ "cancelTitle": "キャンセルキー",
+ "cancelDescription": "録音中の記録をキャンセルするキー"
},
"microphone": {
"description": "ディクテーションに使用する入力デバイスを選択",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index c3ca9aabb..af0cae517 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -1056,7 +1056,9 @@
"activationMode": "Modo de ativação",
"description": "A combinação de teclas que inicia e para o ditado por voz",
"resetToDefault": "Redefinir para {{hotkey}}",
- "title": "Atalho de ditado"
+ "title": "Atalho de ditado",
+ "cancelTitle": "Atalho de cancelamento",
+ "cancelDescription": "Tecla para cancelar uma gravação em andamento"
},
"microphone": {
"description": "Selecione qual dispositivo de entrada usar para ditado",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 6d2098981..ca81a3cde 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -1084,7 +1084,9 @@
"activationMode": "Режим активации",
"description": "Комбинация клавиш для запуска и остановки голосовой диктовки",
"resetToDefault": "Сбросить на {{hotkey}}",
- "title": "Горячая клавиша диктовки"
+ "title": "Горячая клавиша диктовки",
+ "cancelTitle": "Клавиша отмены",
+ "cancelDescription": "Клавиша для отмены текущей записи"
},
"microphone": {
"description": "Выберите устройство ввода для диктовки",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index ba3b70461..7e3746a82 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -1080,7 +1080,9 @@
"activationMode": "激活模式",
"description": "用于开始和停止语音听写的组合键",
"resetToDefault": "重置为 {{hotkey}}",
- "title": "听写快捷键"
+ "title": "听写快捷键",
+ "cancelTitle": "取消快捷键",
+ "cancelDescription": "取消进行中录音的按键"
},
"microphone": {
"description": "选择用于听写的输入设备",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index b5c023d63..0a6b3d07a 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -1080,7 +1080,9 @@
"activationMode": "啟用模式",
"description": "用來開始和停止語音輸入的組合鍵",
"resetToDefault": "重置為 {{hotkey}}",
- "title": "語音輸入快捷鍵"
+ "title": "語音輸入快捷鍵",
+ "cancelTitle": "取消快捷鍵",
+ "cancelDescription": "取消進行中錄音的按鍵"
},
"microphone": {
"description": "選擇用於語音輸入的輸入裝置",
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index bfb84313c..b7b68a774 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -135,6 +135,7 @@ export interface SettingsState
setCustomReasoningApiKey: (key: string) => void;
setDictationKey: (key: string) => void;
+ setCancelKey: (key: string) => void;
setActivationMode: (mode: "tap" | "push") => void;
setPreferBuiltInMic: (value: boolean) => void;
@@ -256,6 +257,7 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
customReasoningApiKey: readString("customReasoningApiKey", ""),
dictationKey: readString("dictationKey", ""),
+ cancelKey: readString("cancelKey", "Escape"),
activationMode: (readString("activationMode", "tap") === "push" ? "push" : "tap") as
| "tap"
| "push",
@@ -414,6 +416,11 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
}
},
+ setCancelKey: (key: string) => {
+ if (isBrowser) localStorage.setItem("cancelKey", key);
+ set({ cancelKey: key });
+ },
+
setActivationMode: (mode: "tap" | "push") => {
if (isBrowser) localStorage.setItem("activationMode", mode);
set({ activationMode: mode });