Skip to content

Fix hotkey triggering logic for subset combinations and exact matching #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ChangJunPark
Copy link

This PR includes two important improvements to the hotkey handling system:

  1. Priority-based processing: Hotkeys with more keys are processed first.
    For example, if both Cmd+C and Cmd+Shift+C are registered, pressing
    Cmd+Shift+C will only trigger the action registered for Cmd+Shift+C.

  2. Exact matching: The number of pressed keys must exactly match the number
    of registered keys for an action to be executed. This prevents unregistered
    combinations (e.g., Cmd+Alt+Shift+A) from accidentally triggering
    other actions.

Additionally, this PR adds a comprehensive test suite covering various hotkey scenarios:

  • Basic single key and modifier key combinations (Cmd+C)
  • Triple key combinations (Cmd+Shift+S)
  • Special key combinations (Shift+F1)
  • Numpad key combinations (Ctrl+Numpad1)
  • Subset hotkey behavior (Cmd+C vs Cmd+Shift+C)
  • Extra keys handling (pressing Cmd+Alt+Shift+A when only Cmd+Shift+A is registered)

These tests validate the improved behavior and ensure future changes won't break
these important use cases. The changes make qHotKeys behavior more predictable and intuitive,
better aligning with standard shortcut behavior in operating systems and applications.

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