Skip to content

Show a shortcut the way the keyboard shows it - #529

Merged
mgth merged 1 commit into
masterfrom
shortcut-readable-display
Jul 31, 2026
Merged

Show a shortcut the way the keyboard shows it#529
mgth merged 1 commit into
masterfrom
shortcut-readable-display

Conversation

@mgth

@mgth mgth commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Follow-up to #528, which left the recorder displaying Ctrl+Oem7. Honest — that is what gets registered — but nobody pressed "Oem7", they pressed ².

It now reads Ctrl+² on an AZERTY board and Ctrl+' on a US one.

Only the display changes

A shortcut is stored, sent and registered as a position. That is what RegisterHotKey takes, and it is what makes a recorded shortcut mean the same physical key after a layout change. Nothing about that moves here.

The character is looked up at display time with MapVirtualKey(VK_TO_CHAR), so switching layouts changes what is shown without invalidating the setting, the wire, or the registration.

It falls back to the position name whenever there is no character to show — a key that prints nothing, a control character, a lookup that fails. Never a blank button, never half-translated. Keys that already read as themselves (M, F12, Space, NumPad0) are not put through it at all.

The cost, stated

This adds a third table to keep in step: the virtual-key codes on the C# side have to be the daemon's. Drift there would point the display at one key and the registration at another, with nothing to notice — so they are asserted here as they already were in shortcut.rs.

The display tests assert shape rather than characters, since Oem7 prints ² on the author's keyboard and ' on the CI runner: the result must be either a single character or the position name.

Tests

129 in the UI suite (was 113); 105 + 60 + 5 elsewhere, 56 Rust — all unchanged.

The recorder displayed Ctrl+Oem7. Honest — that is what gets registered —
but nobody pressed "Oem7", they pressed ². It now reads Ctrl+² on an AZERTY
board and Ctrl+' on a US one.

Only the display changes. A shortcut is stored, sent and registered as a
position, because that is what RegisterHotKey takes and what makes a
recorded shortcut mean the same physical key after a layout change. The
character is looked up at display time with MapVirtualKey(VK_TO_CHAR), so
switching layouts changes what is shown without invalidating anything.

Falls back to the position name whenever there is no character to show — a
key that prints nothing, a control character, a failed lookup. Never a blank
button, never half-translated. Keys that already read as themselves (M, F12,
Space, NumPad0) are not put through it at all.

This does add a third table to keep in step: the virtual-key codes on the C#
side must be the daemon's. Drift there would point the display and the
registration at two different keys with nothing to notice — so they are
asserted here as they already were in shortcut.rs.

The display tests assert shape, not characters: Oem7 prints ² here and ' on
the CI runner, so they pin that the result is either a single character or
the position name.
@mgth
mgth merged commit 4db7223 into master Jul 31, 2026
1 check passed
@mgth
mgth deleted the shortcut-readable-display branch July 31, 2026 20:24
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