Name Print Screen, Menu and media keys as the backends do; repair more legacy key names - #159
Merged
Merged
Conversation
…e legacy names The recorders named any key without a rule after its DOM code, so Print Screen was saved as KEY_PRINTSCREEN, the Menu key as KEY_CONTEXTMENU and Mute as KEY_AUDIOVOLUMEMUTE. No backend reports those names, so such a shortcut could never fire. They now map to KEY_SYSRQ, KEY_COMPOSE and the evdev media names, with readable keycap labels. Loading now also repairs those DOM names, KEY_NUMPADENTER, and letters the old TTS stop key recorder saved without the underscore (KEYV -> KEY_V), in both the stop key and bindings.toml. KEY_* stays as it is: it could be the keypad * or Shift+8. The portal translates every key in keymap::NAMES now (Print, Menu, Pause, Num/Scroll Lock, the ISO 102nd key and the media keys), and two new tests keep the three sides in step: the recorder's output is checked against keymap::NAMES, and every name there must have a portal keysym. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015v84hAqhDBdwy7Q49gAWBR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #157. It brings over the parts of the closed #158 that #157 didn't cover.
Problem
Some keys are still saved under names no backend reports. The recorder names any key it has no rule for after its DOM code:
KEY_PRINTSCREEN;KEY_CONTEXTMENU;KEY_AUDIOVOLUMEMUTE, and likewise for the other media keys.The backends report
KEY_SYSRQ,KEY_COMPOSE,KEY_MUTEand so on, and the key matcher compares names exactly, so these shortcuts never fire.TTS stop keys saved before v0.7.1 can still be broken. The old TTS stop-key recorder saved letters without the underscore (
KEYV). Code review: fix TTS response-pipe bug, dedupe transcription finishing, trim hot-path I/O #157 fixed the recorder but did not repair stop keys already saved that way.Changes
src/lib/keys.ts: mapsPrintScreen→KEY_SYSRQ,ContextMenu→KEY_COMPOSE, and the seven media keys to their evdev names. The wizard gets keycap labels for these (PrtSc, Menu, Mute, Vol +, …).Load-time repair (
canonical_key_name): now also repairs:KEY_NUMPADENTER→KEY_KPENTER;KEYA…KEYZ→KEY_A…KEY_Z.This applies to both the TTS stop key and
bindings.toml.Deliberately not repaired:
KEY_*, which could be the keypad*or Shift+8. The repair Record punctuation, keypad and right-side modifier keys under evdev names #158 made could move a binding to the wrong key.Portal (
trigger.rs): every key inkeymap::NAMESnow has a keysym. The new ones are:less);Before this, the portal refused shortcuts that used these keys.
Tests
tests/svelte/keys.test.ts(new): readskeymap::NAMESfromwin_keys.rsand checks that every key name the recorder can produce is in it.KEY_KPEQUALis the one allowed exception: it is a valid Linux name with no Windows scan code. I checked that this test fails on the old mapping (it reportsKEY_PRINTSCREENandKEY_AUDIOVOLUMEMUTE).trigger.rs): every name inkeymap::NAMESmust translate to a keysym.KEY_A,KEY_KP1,KEYBOARD) and the ambiguousKEY_*are left alone.Verification
cargo testpasses for voxctrl-config, voxctrl-hotkeys and voxctrl-routing.cargo clippy --all-targetson those crates reports no warnings.svelte-checkreports 0 errors and 0 warnings.vitestpasses 264/264.dist/is rebuilt.🤖 Generated with Claude Code
https://claude.ai/code/session_015v84hAqhDBdwy7Q49gAWBR
Generated by Claude Code