Cw
2026-07-04 fecea2c7a4ecc48b2354868894e78be361a2ccf1
C1.source/privatevoice.src/frontend/src/components/settings/HotkeysPage.svelte
@@ -1,4 +1,5 @@
<script lang="ts">
  import { onDestroy } from 'svelte'
  import { Call } from '@wailsio/runtime'
  import { t } from '../../lib/i18n'
  import { hotkeyVK } from '../../lib/stores/config'
@@ -7,10 +8,17 @@
  let currentKeyName = $state('Ctrl')
  let isRecording = $state(false)
  let hintText = $state('')
  let activeKeyHandler: ((e: KeyboardEvent) => void) | null = null
  const unsub = hotkeyName.subscribe(k => { currentKeyName = k })
  onDestroy(() => {
    unsub()
    clearHotkeyCapture()
  })
  async function startRecordingHotkey() {
    clearHotkeyCapture()
    isRecording = true
    hintText = t('hotkeys.pressAnyKey')
@@ -44,13 +52,25 @@
          } catch {}
        })()
        document.removeEventListener('keydown', onKey)
        clearHotkeyCapture()
      }
    }
    activeKeyHandler = onKey
    document.addEventListener('keydown', onKey)
  }
  function clearHotkeyCapture() {
    if (activeKeyHandler) {
      document.removeEventListener('keydown', activeKeyHandler)
      activeKeyHandler = null
    }
    if (isRecording) {
      isRecording = false
      void Call.ByName('voicesnap/services.HotkeyService.StopRecordingHotkey').catch(() => {})
    }
  }
  function mapKeyToVK(e: KeyboardEvent): number {
    // Map browser key codes to Windows VK codes
    switch (e.key) {