Skip to content

Conversation

Copy link

Copilot AI commented Aug 11, 2025

This PR implements comprehensive keyboard shortcut customization for WhispLine, replacing the hardcoded Ctrl+Shift and Shift+Alt combinations with a user-friendly customization system.

Changes Made

Backend (main.js):

  • Replaced hardcoded key state tracking with generic pressedKeys Set and isShortcutPressed() helper function
  • Added DEFAULT_SHORTCUTS configuration with fallback to original Ctrl+Shift (transcription) and Shift+Alt (translation)
  • Updated setupGlobalHotkeys() to use stored shortcuts from electron-store instead of hardcoded combinations
  • Added comprehensive key mapping support for modifier keys, function keys, arrow keys, and alphanumeric keys
  • Implemented automatic shortcut restart when settings are saved
  • Added IPC handler for shortcut validation

Frontend (settings.html):

  • Enhanced the existing shortcut settings section to display current shortcuts
  • Created modal interface for recording new key combinations with real-time visual feedback
  • Added shortcut validation to prevent duplicate combinations and enforce minimum requirements
  • Implemented key recording using browser KeyboardEvent API with proper event handling
  • Added reset functionality to restore default shortcuts

Key Features

  • Live Recording: Click "Record" and press your desired key combination - it's captured instantly
  • Visual Feedback: Recording state is clearly indicated with color changes and status text
  • Validation: Prevents identical shortcuts and requires at least one key per combination
  • Hot Reload: New shortcuts take effect immediately without app restart
  • Comprehensive Support: Works with Ctrl, Shift, Alt, Cmd, function keys, arrow keys, and letters/numbers

Usage

  1. Open Settings (Cmd/Ctrl+, or via tray menu)
  2. Click "Customize Shortcuts" in the General section
  3. Click "Record" next to the shortcut you want to change
  4. Press and hold your desired key combination
  5. Click "Save" to apply changes

Settings Interface

Shortcut Customization Modal

The implementation maintains backward compatibility with existing installations while providing the flexibility users requested for custom shortcut configurations.

Fixes #9.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 11, 2025 00:26
Co-authored-by: hellotaotao <1796860+hellotaotao@users.noreply.github.com>
Co-authored-by: hellotaotao <1796860+hellotaotao@users.noreply.github.com>
Copilot AI changed the title [WIP] shortcut custimisation Implement keyboard shortcut customization for voice input Aug 11, 2025
Copilot AI requested a review from hellotaotao August 11, 2025 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shortcut custimisation

2 participants