Skip to content

fix(keyboard): KeyModifier string parser no longer strips hyphen from key - #103

Merged
windingwind merged 1 commit into
windingwind:mainfrom
northword:fix/keymodifier-parse-hyphen
Jul 21, 2026
Merged

windingwind merged 1 commit into
windingwind:mainfrom
northword:fix/keymodifier-parse-hyphen

Conversation

@northword

Copy link
Copy Markdown
Contributor

Problem

new KeyModifier("accel,-") results in km.key === "" instead of km.key === "-".

The string constructor at src/managers/keyboard.ts:191 strips characters with regex [ ,\-]. The - was intended as a separator for hyphen-separated input formats (e.g. Ctrl-Shift-B), but the canonical format used throughout KeyModifier is comma-separated (from getRaw()).

Impact

Any key that contains or equals a hyphen (e.g. -, =, or other special characters that might be affected) is lost when constructing from raw strings. This affects downstream plugins that use KeyModifier for shortcut display and comparison.

Reproduction

const km = new KeyModifier("accel,-");
console.log(km.key); // "" — should be "-"

Fix

Remove - from the separator character class in the regex. The comma key is still handled correctly by the existing fallback on line 194.

The hyphen-separated format (e.g. Ctrl-Shift-B) was never used internally by any part of the toolkit, so this change does not break existing functionality.

… key

The regex in the string constructor was intended for hyphen-separated input formats (e.g. Ctrl-Shift-B), but the canonical format used throughout KeyModifier is comma-separated (from getRaw()). Stripping hyphens breaks legitimate key characters in raw strings such as accel,-.

Remove hyphen from the separator character class. The comma key is still handled by the existing fallback.
@windingwind
windingwind merged commit f02dd47 into windingwind:main Jul 21, 2026
3 checks passed
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.

2 participants