Skip to content

Add Multiple Modifier Key Support for Activation Hotkeys#5

Open
O-mkar wants to merge 2 commits intoWorldOfBasti:masterfrom
O-mkar:feature/modifier-key-support
Open

Add Multiple Modifier Key Support for Activation Hotkeys#5
O-mkar wants to merge 2 commits intoWorldOfBasti:masterfrom
O-mkar:feature/modifier-key-support

Conversation

@O-mkar
Copy link

@O-mkar O-mkar commented Feb 28, 2026

Add Multiple Modifier Key Support for Activation Hotkeys

🎯 Overview

Added support for modifier keys (⌘ Command, ⌥ Option, ⇧ Shift, ⌃ Control) in combination with activation hotkeys, enabling more flexible and conflict-free hotkey configurations.

✨ What's New

Previously, users could only set single keys (e.g., "4") as activation hotkeys. Now you can use modifier combinations like:

  • ⇧4 (Shift + 4)
  • ⌘C (Command + C)
  • ⌃⌥⇧A (Control + Option + Shift + A)

🔧 Changes

Modified Files

  • MainViewController.swift
  • KeyCodeToCharTransformer.swift
  • KeyPopoverViewController.swift

Key Features

  • ✅ Capture and save modifier key combinations
  • ✅ Display activation keys with standard macOS modifier symbols (⌃⌥⇧⌘)
  • ✅ Exact modifier matching for activation
  • ✅ Persistent storage of modifier preferences
  • ✅ Backward compatible with existing single-key configurations

📋 Technical Details

New Data Storage

// UserDefaults keys
"ActivationKey"        // Key code (existing)
"ActivationModifiers"  // Modifier flags (NEW)

- AutoClicker: add activationModifiers computed property reading ActivationModifiers
  from UserDefaults; replace inline key check with matchesActivationKey() that
  verifies both key code and modifier state (Command/Option/Shift/Control only)
- KeyCodeToCharTransformer: read ActivationModifiers from UserDefaults and prepend
  standard macOS symbols (⌃⌥⇧⌘) to the displayed key character
- KeyPopoverViewController: update delegate protocol to pass NSEvent.ModifierFlags
  alongside keyCode; filter to relevant modifiers before forwarding
- MainViewController: update keySelected() to save relevant modifiers to
  ActivationModifiers before saving ActivationKey (IB binding triggers display update)
- Fix pre-existing bug: right mouse-up event was incorrectly sending leftMouseUp

Made-with: Cursor
IB binding only re-evaluates KeyCodeToCharTransformer when ActivationKey
changes. Removing the key before re-setting forces a value change even
when the same key code is reused with different modifiers (e.g. 4 -> Shift+4).

Made-with: Cursor
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.

1 participant