Repository navigation
gpui: add the physical key code to Keystroke - #14
Open
Cyberistic wants to merge 2 commits into
Open
Cyberistic wants to merge 2 commits into
Cyberistic wants to merge 2 commits into
Conversation
`Keystroke::code` carries the layout-independent physical key in the DOM `KeyboardEvent.code` spelling (`"KeyS"`, `"Digit1"`, `"ArrowLeft"`), or `None` when the platform cannot report one. `key` keeps describing the character the layout produced, so keybinding parsing, matching, and `Display` are untouched; the field is `#[serde(default)]` so keystrokes serialized before it existed still decode. The mapping tables live in `gpui::keystroke_code` as pure functions, one per platform, so every host can unit-test all of them: - macOS: `NSEvent.keyCode` (`kVK_*`) - Windows: the Set 1 scancode from `WM_KEYDOWN`, with the extended flag - Linux: the xkb key code, i.e. the evdev code plus 8 The macOS, Windows, Linux, and web backends fill the field in where they build a keystroke; synthesized keystrokes leave it `None`. Unblocks remorses/gpuix#105.
Cyberistic
marked this pull request as ready for review
October 25, 2026 04:24
Checked every entry against Chromium's `dom_code_data.inc`: - macOS `kVK_Help` (0x72) sits in the Insert position and browsers report it as `Insert`, not `Help`; JIS Eisu and Kana are `Lang2` and `Lang1`. - Windows reports Pause as the plain scan code 0x45 and NumLock as the extended 0x45; the table had NumLock on the plain code and no Pause. Extended 0x37 is PrintScreen. - evdev 128 (`KEY_STOP`) is `BrowserStop`; `MediaStop` is 166 (`KEY_STOPCD`). The Windows table also gains the keys the other two already map: NumpadEqual, NumpadComma, Lang1, Lang2, Power and the browser keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Tested on mac only, need it for https://github.com/remorses/gpuix#105.
Adds the physical key code to
Keystroke, so a binding or an app can match a key that does not move with the layout (KeySon AZERTY is still the S position).