Skip to content

Refine hotkey validation: disallow Windows modifier and modifier virtual keys, add VK constants and tests - #13

Open
stuartd wants to merge 1 commit into
mainfrom
codex/fix-hotkeymodifiers-windows-flag-behavior-kqjw5h
Open

stuartd wants to merge 1 commit into
mainfrom
codex/fix-hotkeymodifiers-windows-flag-behavior-kqjw5h

Conversation

@stuartd

@stuartd stuartd commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent assigning modifier keys or the Windows modifier bit as a primary shortcut key and disallow unsafe/incomplete shortcuts like plain Shift or Alt+F4.
  • Make virtual-key handling explicit and robust by naming VK constants and centralizing modifier virtual-key detection.
  • Improve validation rules to enforce sane VK boundaries and supported modifier combinations.

Description

  • Remove the Windows flag from HotKeyModifiers and stop treating the Windows modifier as supported.
  • Add named VirtualKey* constants and build a ModifierVirtualKeys set to explicitly recognize keys that are modifiers and therefore cannot be the primary key.
  • Tighten IsValid to require at least one primary modifier (Control or Alt), reject unsupported modifier bits, enforce VK range bounds, exclude Windows key VKs and modifier VKs, and disallow Alt+F4.
  • Remove a redundant DisplayText special-case and rely on IsValid, and expand/adjust unit tests in HotKeyGestureTests to cover boundary cases and unsupported flags.

Testing

  • Ran the updated unit test file tests/ClipDiff.Windows.Tests/HotKeyGestureTests.cs via dotnet test for the ClipDiff.Windows.Tests project.
  • All tests in HotKeyGestureTests passed successfully.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant