Skip to content

Fold browser and Silk.NET letter and digit key names into the plain key [patch] - #219

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/218-browser-silk-key-names
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/218-browser-silk-key-names

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #218

What changed

#205 taught CanonicalizeKey the modifier names that browsers and Silk.NET send, but not their letter and digit names. So ControlLeft+KeyS became Ctrl+KEYS and never matched a stored Ctrl+S.

CanonicalizeKey (Keybinding/Models/MusicalTypes.cs) now folds these, next to the existing WinForms D0-D9 rule:

  • KEY plus exactly one letter (browser KeyA-KeyZ) folds to the letter
  • DIGIT plus one digit (browser Digit0-Digit9) and NUMBER plus one digit (Silk.NET Number0-Number9) fold to the digit

Numpad names (Numpad1, NumPad1, Keypad1) stay distinct. So do near-misses such as Key1, KeyAB, Digit10 and NumberA.

Tests

  • ChordParse_KeyAliasesMatchCanonicalName has new rows for KeyA/KeyS/KeyZ, Digit0/1/9 and Number0/1/9. Each checks equality, the hash, and the NoteName constructor.
  • ChordParse_BrowserAndSilkKeyNames_DisplayAsCanonicalChord covers the issue's cases: ControlLeft+KeyS equals Ctrl+S and displays as Ctrl+S, and the same for Digit1 and Number1.
  • NoteConstructor_OtherKeyNamesStayDistinct checks that the numpad names and near-misses are left as they are.

With the fix reverted, 13 of the new cases fail. With it, the full suite passes (405/405).


Generated by Claude Code

…ey [patch]

Browsers send KeyA-KeyZ and Digit0-Digit9 (KeyboardEvent.code) and Silk.NET
sends Number0-Number9, so `ControlLeft+KeyS` parsed as `Ctrl+KEYS` and never
matched a stored `Ctrl+S`. CanonicalizeKey now folds these next to the
WinForms D0-D9 rule. Numpad and keypad names stay distinct.

Fixes #218

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW26R7a4LaEL6NnFvBq
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

2 participants