Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

feat: add the record keys setting to the extension, off by default like the desktop

Luis Ortiz732194ef0c79
diff --git a/apps/desktop/src/renderer/settings/SettingsPanel.tsx b/apps/desktop/src/renderer/settings/SettingsPanel.tsx
index abcc1ae..bde93df 100644
--- a/apps/desktop/src/renderer/settings/SettingsPanel.tsx
+++ b/apps/desktop/src/renderer/settings/SettingsPanel.tsx
@@ -170,7 +170,7 @@ export function SettingsPanel() {
</Row>
</Card>
- <Card icon={Keyboard} title={i18n.t('desktop_cardKeyboard')} hint={i18n.t('desktop_cardKeyboardHint')}>
+ <Card icon={Keyboard} title={i18n.t('settings_cardKeyboard')} hint={i18n.t('settings_cardKeyboardHint')}>
<Row label={i18n.t('desktop_recordTyping')} hint={i18n.t('desktop_recordTypingHint')}>
<Switch
checked={settings.recordTyping}
@@ -190,10 +190,10 @@ export function SettingsPanel() {
onChange={(typingDebounceMs) => save({ typingDebounceMs })}
/>
</Row>
- <Row label={i18n.t('desktop_recordKeys')} hint={i18n.t('desktop_recordKeysHint')}>
+ <Row label={i18n.t('settings_recordKeys')} hint={i18n.t('settings_recordKeysHint')}>
<Switch
checked={settings.recordKeys}
- label={i18n.t('desktop_recordKeys')}
+ label={i18n.t('settings_recordKeys')}
onChange={(recordKeys) => save({ recordKeys })}
/>
</Row>
diff --git a/packages/core/src/guides/types.ts b/packages/core/src/guides/types.ts
index a64a02e..812e8f4 100644
--- a/packages/core/src/guides/types.ts
+++ b/packages/core/src/guides/types.ts
@@ -102,6 +102,7 @@ export interface Settings {
guideMeManual: boolean;
onboardingCompleted: boolean;
appLanguage: string;
+ recordKeys: boolean;
}
export type SettingsKey = keyof Settings;
diff --git a/src/capture/events/__tests__/is-recordable-key.test.ts b/src/capture/events/__tests__/is-recordable-key.test.ts
new file mode 100644
index 0000000..ba5ac80
--- /dev/null
+++ b/src/capture/events/__tests__/is-recordable-key.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest';
+import { isRecordableKey } from '../is-recordable-key';
+
+const press = (key: string, mods: Partial<{ ctrlKey: boolean; metaKey: boolean; altKey: boolean }> = {}) => ({
+ key,
+ ctrlKey: false,
+ metaKey: false,
+ altKey: false,
+ ...mods,
+});
+
+describe('isRecordableKey', () => {
+ it('records shortcuts and named keys, like the desktop', () => {
+ expect(isRecordableKey(press('s', { ctrlKey: true }))).toBe(true);
+ expect(isRecordableKey(press('k', { metaKey: true }))).toBe(true);
+ expect(isRecordableKey(press('Enter'))).toBe(true);
+ expect(isRecordableKey(press('ArrowDown'))).toBe(true);
+ });
+
+ it('skips plain characters and a modifier pressed on its own', () => {
+ expect(isRecordableKey(press('a'))).toBe(false);
+ expect(isRecordableKey(press('A'))).toBe(false);
+ expect(isRecordableKey(press('Shift'))).toBe(false);
+ expect(isRecordableKey(press('Control', { ctrlKey: true }))).toBe(false);
+ });
+});
diff --git a/src/capture/events/handlers.ts b/src/capture/events/handlers.ts
index d7c07ea..c464d6f 100644
--- a/src/capture/events/handlers.ts
+++ b/src/capture/events/handlers.ts
@@ -19,6 +19,7 @@ import { DEFAULT_TARGET_COLOR } from '@/core/screenshot/types';
import { localStorage } from '@/lib/browser-api/local-storage';
import { HoverRing } from '@/lib/hover-ring';
import { InputSession } from './input-session';
+import { isRecordableKey } from './is-recordable-key';
const DEDUP_MS = 300;
const DRAG_MIN_PX = 30;
@@ -68,6 +69,7 @@ class CaptureController {
private ring = new HoverRing(DEFAULT_TARGET_COLOR);
private hovered: HTMLElement | null = null;
private busy = false;
+ private recordKeys = false;
constructor(
private guideId: string,
@@ -100,6 +102,12 @@ class CaptureController {
})
.catch(() => {});
}
+ localStorage
+ .get(['recordKeys'])
+ .then(({ recordKeys }) => {
+ this.recordKeys = recordKeys === true;
+ })
+ .catch(() => {});
for (const [event, handler, opts] of this.listeners) {
window.addEventListener(event, handler, opts);
}
@@ -235,6 +243,7 @@ class CaptureController {
}
if (isSensitiveField(target) || isTextField(target)) return;
+ if (!this.recordKeys || !isRecordableKey(ke)) return;
this.enqueue(this.capture(`keydown:${ke.key}`, target));
}
diff --git a/src/capture/events/is-recordable-key.ts b/src/capture/events/is-recordable-key.ts
new file mode 100644
index 0000000..0b1afcd
--- /dev/null
+++ b/src/capture/events/is-recordable-key.ts
@@ -0,0 +1,16 @@
+const NOT_STEPS = new Set([
+ 'Shift',
+ 'Control',
+ 'Alt',
+ 'Meta',
+ 'AltGraph',
+ 'CapsLock',
+ 'Dead',
+ 'Unidentified',
+ 'Process',
+]);
+
+export function isRecordableKey(key: { key: string; ctrlKey: boolean; metaKey: boolean; altKey: boolean }): boolean {
+ if (NOT_STEPS.has(key.key)) return false;
+ return key.ctrlKey || key.metaKey || key.altKey || key.key.length > 1;
+}
diff --git a/src/locales/de.yml b/src/locales/de.yml
index 7866c25..249c3f9 100644
--- a/src/locales/de.yml
+++ b/src/locales/de.yml
@@ -90,6 +90,10 @@ recording:
minutesAgo: "vor $1 Min."
settings:
+ cardKeyboard: "Tippen und Tasten"
+ cardKeyboardHint: "Was deine Tastatur zu einer Anleitung beiträgt."
+ recordKeys: "Kürzel und benannte Tasten aufzeichnen"
+ recordKeysHint: "Strg+S, Enter und Ähnliches werden zu Schritten."
microphoneAccess: "Mikrofonzugriff"
microphoneAccessAsk: "Dein Browser fragt einmal, bevor Mimik dich hören kann."
microphoneAccessAllow: "Erlauben"
@@ -243,23 +247,19 @@ desktop:
upToDate: "Auf dem neuesten Stand"
upToDateMessage: "Mimik $1 ist aktuell."
cardScreenshots: "Screenshots"
- cardKeyboard: "Tippen und Tasten"
cardGlobalKeys: "Globale Tasten"
cardGlobalKeysHint: "Werden jeder Anwendung entzogen, solange Mimik läuft."
zoomLevel: "Auf den Klick zoomen"
zoomLevelHint: "Neue Aufzeichnungen starten hier. Automatisch hält alle Schritte gleich groß."
zoomAuto: "Automatisch"
zoomGuide: "Zoom"
- recordKeys: "Kürzel und benannte Tasten aufzeichnen"
recordTyping: "Eingaben aufzeichnen"
recordTypingHint: "Alles, was du in ein Feld tippst, wird ein Schritt."
typingDebounce: "Eingabeschritt beenden nach"
typingDebounceHint: "Eine so lange Pause beendet den Eingabeschritt."
cardScreenshotsHint: "Was der Screenshot jedes Schritts zeigt."
- cardKeyboardHint: "Was deine Tastatur zu einer Anleitung beiträgt."
captureModeHint: "Fenster folgt der App, die du anklickst."
screenshotDelayHint: "Wartezeit vor dem Screenshot, für Menüs mit Animation."
- recordKeysHint: "Strg+S, Enter und Ähnliches werden zu Schritten."
seconds: "s"
shortcutStartStop: "Aufnahme starten oder beenden"
shortcutPauseResume: "Pausieren oder fortsetzen"
diff --git a/src/locales/en.yml b/src/locales/en.yml
index 58bf223..bc0c0e4 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -90,6 +90,10 @@ recording:
minutesAgo: "$1m ago"
settings:
+ cardKeyboard: "Typing and keys"
+ cardKeyboardHint: "What your keyboard adds to a guide."
+ recordKeys: "Record shortcuts and named keys"
+ recordKeysHint: "Ctrl+S, Enter and the like become steps."
microphoneAccess: "Microphone access"
microphoneAccessAsk: "Your browser asks once before Mimik can hear you."
microphoneAccessAllow: "Allow"
@@ -243,23 +247,19 @@ desktop:
upToDate: "Up to date"
upToDateMessage: "Mimik $1 is current."
cardScreenshots: "Screenshots"
- cardKeyboard: "Typing and keys"
cardGlobalKeys: "Global keys"
cardGlobalKeysHint: "Taken from every application while Mimik is running."
zoomLevel: "Zoom toward the click"
zoomLevelHint: "New recordings start here. Automatic keeps every step the same size."
zoomAuto: "Automatic"
zoomGuide: "Zoom"
- recordKeys: "Record shortcuts and named keys"
recordTyping: "Record what you type"
recordTypingHint: "Everything you type into one field becomes one step."
typingDebounce: "Close a typing step after"
typingDebounceHint: "A pause this long ends the typing step."
cardScreenshotsHint: "What each step's screenshot shows."
- cardKeyboardHint: "What your keyboard adds to a guide."
captureModeHint: "Window follows the app you click."
screenshotDelayHint: "Wait before taking the screenshot, for menus that animate."
- recordKeysHint: "Ctrl+S, Enter and the like become steps."
seconds: "s"
shortcutStartStop: "Start or finish a recording"
shortcutPauseResume: "Pause or resume"
diff --git a/src/locales/es.yml b/src/locales/es.yml
index d1d6f05..06a069f 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -90,6 +90,10 @@ recording:
minutesAgo: "hace $1m"
settings:
+ cardKeyboard: "Escritura y teclas"
+ cardKeyboardHint: "Lo que tu teclado añade a una guía."
+ recordKeys: "Registrar atajos y teclas con nombre"
+ recordKeysHint: "Ctrl+S, Enter y similares se convierten en pasos."
microphoneAccess: "Acceso al micrófono"
microphoneAccessAsk: "Tu navegador pregunta una vez antes de que Mimik pueda oírte."
microphoneAccessAllow: "Permitir"
@@ -243,23 +247,19 @@ desktop:
upToDate: "Actualizado"
upToDateMessage: "Mimik $1 es la versión más reciente."
cardScreenshots: "Capturas de pantalla"
- cardKeyboard: "Escritura y teclas"
cardGlobalKeys: "Teclas globales"
cardGlobalKeysHint: "Se toman de todas las aplicaciones mientras Mimik está en ejecución."
zoomLevel: "Acercar hacia el clic"
zoomLevelHint: "Las grabaciones nuevas empiezan aquí. Automático mantiene todos los pasos del mismo tamaño."
zoomAuto: "Automático"
zoomGuide: "Zoom"
- recordKeys: "Registrar atajos y teclas con nombre"
recordTyping: "Registrar lo que escribes"
recordTypingHint: "Todo lo que escribes en un campo se convierte en un paso."
typingDebounce: "Cerrar el paso de escritura tras"
typingDebounceHint: "Una pausa así de larga cierra el paso de escritura."
cardScreenshotsHint: "Lo que muestra la captura de cada paso."
- cardKeyboardHint: "Lo que tu teclado añade a una guía."
captureModeHint: "Ventana sigue a la app en la que haces clic."
screenshotDelayHint: "Espera antes de la captura, para menús con animación."
- recordKeysHint: "Ctrl+S, Enter y similares se convierten en pasos."
seconds: "s"
shortcutStartStop: "Iniciar o finalizar una grabación"
shortcutPauseResume: "Pausar o reanudar"
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index f26ef28..e3f255e 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -90,6 +90,10 @@ recording:
minutesAgo: "Il y a $1 min"
settings:
+ cardKeyboard: "Saisie et touches"
+ cardKeyboardHint: "Ce que votre clavier ajoute à un guide."
+ recordKeys: "Enregistrer les raccourcis et touches nommées"
+ recordKeysHint: "Ctrl+S, Entrée et autres deviennent des étapes."
microphoneAccess: "Accès au micro"
microphoneAccessAsk: "Votre navigateur demande une fois avant que Mimik puisse vous entendre."
microphoneAccessAllow: "Autoriser"
@@ -243,23 +247,19 @@ desktop:
upToDate: "À jour"
upToDateMessage: "Mimik $1 est la dernière version."
cardScreenshots: "Captures d’écran"
- cardKeyboard: "Saisie et touches"
cardGlobalKeys: "Touches globales"
cardGlobalKeysHint: "Prises à toutes les applications tant que Mimik est en cours d’exécution."
zoomLevel: "Zoomer vers le clic"
zoomLevelHint: "Les nouveaux enregistrements partent d’ici. Automatique garde toutes les étapes à la même taille."
zoomAuto: "Automatique"
zoomGuide: "Zoom"
- recordKeys: "Enregistrer les raccourcis et touches nommées"
recordTyping: "Enregistrer ce que vous tapez"
recordTypingHint: "Tout ce que vous tapez dans un champ devient une étape."
typingDebounce: "Clôturer l'étape de saisie après"
typingDebounceHint: "Une pause de cette durée clôt l’étape de saisie."
cardScreenshotsHint: "Ce que montre la capture de chaque étape."
- cardKeyboardHint: "Ce que votre clavier ajoute à un guide."
captureModeHint: "Fenêtre suit l’application sur laquelle vous cliquez."
screenshotDelayHint: "Attente avant la capture, pour les menus animés."
- recordKeysHint: "Ctrl+S, Entrée et autres deviennent des étapes."
seconds: "s"
shortcutStartStop: "Démarrer ou terminer un enregistrement"
shortcutPauseResume: "Mettre en pause ou reprendre"
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index c96db05..5bfd096 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -90,6 +90,10 @@ recording:
minutesAgo: "$1min atrás"
settings:
+ cardKeyboard: "Digitação e teclas"
+ cardKeyboardHint: "O que o seu teclado acrescenta a um guia."
+ recordKeys: "Registrar atalhos e teclas nomeadas"
+ recordKeysHint: "Ctrl+S, Enter e afins viram passos."
microphoneAccess: "Acesso ao microfone"
microphoneAccessAsk: "Seu navegador pergunta uma vez antes que o Mimik possa ouvir você."
microphoneAccessAllow: "Permitir"
@@ -243,23 +247,19 @@ desktop:
upToDate: "Atualizado"
upToDateMessage: "O Mimik $1 é a versão mais recente."
cardScreenshots: "Capturas de tela"
- cardKeyboard: "Digitação e teclas"
cardGlobalKeys: "Teclas globais"
cardGlobalKeysHint: "Retiradas de todos os aplicativos enquanto o Mimik estiver em execução."
zoomLevel: "Aproximar no clique"
zoomLevelHint: "Novas gravações começam aqui. Automático mantém todas as etapas do mesmo tamanho."
zoomAuto: "Automático"
zoomGuide: "Zoom"
- recordKeys: "Registrar atalhos e teclas nomeadas"
recordTyping: "Registrar o que você digita"
recordTypingHint: "Tudo o que você digita em um campo vira uma etapa."
typingDebounce: "Encerrar a etapa de digitação após"
typingDebounceHint: "Uma pausa desse tamanho encerra a etapa de digitação."
cardScreenshotsHint: "O que a captura de cada etapa mostra."
- cardKeyboardHint: "O que o seu teclado acrescenta a um guia."
captureModeHint: "Janela acompanha o app em que você clica."
screenshotDelayHint: "Espera antes da captura, para menus com animação."
- recordKeysHint: "Ctrl+S, Enter e afins viram passos."
seconds: "s"
shortcutStartStop: "Iniciar ou finalizar uma gravação"
shortcutPauseResume: "Pausar ou retomar"
diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml
index ea8d1b6..738cdc0 100644
--- a/src/locales/zh-CN.yml
+++ b/src/locales/zh-CN.yml
@@ -90,6 +90,10 @@ recording:
minutesAgo: "$1 分钟前"
settings:
+ cardKeyboard: "输入与按键"
+ cardKeyboardHint: "键盘为指南添加的内容。"
+ recordKeys: "记录快捷键和命名按键"
+ recordKeysHint: "Ctrl+S、Enter 等会成为步骤。"
microphoneAccess: "麦克风权限"
microphoneAccessAsk: "浏览器会先询问一次,Mimik 才能听到你的声音。"
microphoneAccessAllow: "允许"
@@ -243,23 +247,19 @@ desktop:
upToDate: "已是最新版本"
upToDateMessage: "Mimik $1 已是最新版本。"
cardScreenshots: "屏幕截图"
- cardKeyboard: "输入与按键"
cardGlobalKeys: "全局快捷键"
cardGlobalKeysHint: "Mimik 运行期间会从所有应用程序中接管这些按键。"
zoomLevel: "向点击处缩放"
zoomLevelHint: "新录制从这里开始。自动会让每一步保持相同大小。"
zoomAuto: "自动"
zoomGuide: "缩放"
- recordKeys: "记录快捷键和命名按键"
recordTyping: "记录输入内容"
recordTypingHint: "在一个输入框中输入的内容会成为一个步骤。"
typingDebounce: "输入步骤结束延迟"
typingDebounceHint: "停顿这么久会结束输入步骤。"
cardScreenshotsHint: "每个步骤的截图所显示的内容。"
- cardKeyboardHint: "键盘为指南添加的内容。"
captureModeHint: "窗口模式跟随你点击的应用。"
screenshotDelayHint: "截图前等待,适用于带动画的菜单。"
- recordKeysHint: "Ctrl+S、Enter 等会成为步骤。"
seconds: "秒"
shortcutStartStop: "开始或结束录制"
shortcutPauseResume: "暂停或继续"
diff --git a/src/ui/shared/SettingsView.tsx b/src/ui/shared/SettingsView.tsx
index 4c129eb..35c8c12 100644
--- a/src/ui/shared/SettingsView.tsx
+++ b/src/ui/shared/SettingsView.tsx
@@ -11,7 +11,7 @@ import {
useApiKeys,
VoiceoverSettings,
} from '@mimik/ui';
-import { ArrowLeft, Bug, Check, ChevronRight, EyeOff, Shield, Star } from 'lucide-react';
+import { ArrowLeft, Bug, Check, ChevronRight, EyeOff, Keyboard, Shield, Star } from 'lucide-react';
import { type ReactNode, useCallback, useEffect, useState } from 'react';
import { localStorage } from '@/lib/browser-api/local-storage';
import { sendMessage } from '@/lib/messaging';
@@ -29,6 +29,7 @@ interface SettingsViewProps {
export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
const [section, setSection] = useState<SettingsSection>(() => settingsSection(window.location.hash));
const [loaded, setLoaded] = useState(false);
+ const [recordKeys, setRecordKeys] = useState(false);
const [blurPresets, setBlurPresets] = useState<Record<PresetKey, boolean>>({
email: true,
phone: true,
@@ -39,13 +40,14 @@ export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
});
useEffect(() => {
- localStorage.get(['blurPresets']).then((result) => {
+ localStorage.get(['blurPresets', 'recordKeys']).then((result) => {
if (result.blurPresets) setBlurPresets(result.blurPresets as Record<PresetKey, boolean>);
+ setRecordKeys(result.recordKeys === true);
setLoaded(true);
});
}, []);
- const { saved, queue } = useSettingsAutosave({ blurPresets }, loaded);
+ const { saved, queue } = useSettingsAutosave({ blurPresets, recordKeys }, loaded);
const keys = useApiKeys({ onChange: queue });
const showSection = (next: SettingsSection) => {
@@ -118,6 +120,24 @@ export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
))}
</SettingsCard>
),
+ keys: (
+ <SettingsCard icon={Keyboard} title={i18n.t('settings.cardKeyboard')} hint={i18n.t('settings.cardKeyboardHint')}>
+ <div className="flex items-center justify-between gap-3 py-2">
+ <div className="min-w-0">
+ <p className="text-[11px] font-semibold text-foreground">{i18n.t('settings.recordKeys')}</p>
+ <p className="text-[11px] text-muted-foreground">{i18n.t('settings.recordKeysHint')}</p>
+ </div>
+ <Switch
+ checked={recordKeys}
+ label={i18n.t('settings.recordKeys')}
+ onChange={(on) => {
+ setRecordKeys(on);
+ localStorage.set({ recordKeys: on });
+ }}
+ />
+ </div>
+ </SettingsCard>
+ ),
'api-keys': <ApiKeysSettings state={keys} validate={validateApiKey} title={i18n.t('settings.apiKeys')} />,
};
@@ -179,6 +199,7 @@ export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
{sections.narration}
{sections['voice-over']}
{sections['smart-blur']}
+ {sections.keys}
<div className="flex items-start gap-2 px-3 py-2.5 rounded-lg bg-secondary text-[10px] text-muted-foreground leading-relaxed">
<Shield size={12} className="shrink-0 mt-0.5 text-accent" />
<span>{i18n.t('settings.privacyNotice')}</span>
diff --git a/src/ui/shared/lib/settings-section.ts b/src/ui/shared/lib/settings-section.ts
index d29a113..9920c63 100644
--- a/src/ui/shared/lib/settings-section.ts
+++ b/src/ui/shared/lib/settings-section.ts
@@ -1,4 +1,4 @@
-import { AudioLines, EyeOff, ImageIcon, KeyRound, Mic, Sparkles } from 'lucide-react';
+import { AudioLines, EyeOff, ImageIcon, Keyboard, KeyRound, Mic, Sparkles } from 'lucide-react';
export const SETTINGS_SECTIONS = [
{ id: 'ai', label: 'settings.aiDescriptions', Icon: Sparkles },
@@ -6,6 +6,7 @@ export const SETTINGS_SECTIONS = [
{ id: 'voice-over', label: 'settings.voiceover', Icon: AudioLines },
{ id: 'branding', label: 'settings.branding', Icon: ImageIcon },
{ id: 'smart-blur', label: 'settings.smartBlur', Icon: EyeOff },
+ { id: 'keys', label: 'settings.cardKeyboard', Icon: Keyboard },
{ id: 'api-keys', label: 'settings.apiKeys', Icon: KeyRound },
] as const;