Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Keybindings Editor does not respect users keyboard layout #13229

Closedmbeckenbach(GitHub profile, opens in a new tab) opened this issue 2 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Use a non english keyboard layout (e.g. German Mac)
  2. Try to change a hotkey in settings (e.g. use shift+#)

Note: Same issue applies to the Snapshots feature hotkey editing.

Expected behavior

The UI should receive and display the actual kex/compo pressed on my physical keyboard.

Actual behavior

Hotkey from my example using german keyboard (shift+#) gets mapped to shift+\ which indicates a english/us keyboard layout.

Impact

Minor bug or occasional failure

Version or commit

0.0.43-nightly.20260923.2135

Environment

macOS 27

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

No response

  1. mbeckenbach(GitHub profile, opens in a new tab) added labelsneeds-triage

  2. Triage

    Confirmed on current main (f5ef0ddb9). The nightly in this report (0.0.43-nightly.20260923.2135) already contains it. Not already fixed.

    What you reported. On a German Mac layout, recording Shift plus the # key in Settings → Keybindings shows shift+\. The same recorder is used for SnapShots. Letters are fine. This key is not.

    That is what the recorder does. On the German ISO layout (including German on macOS), the key left of Return is labeled # unshifted and ' with Shift. The browser reports that physical key as KeyboardEvent.code === "Backslash". The recorder throws away both # and ' and stores the US name of that code, \, then adds shift because Shift was held. shift+\ is the only value in the shortcut map that produces a backslash.

    What the code does

    1. Any non-letter in the US code map is stored as the US glyph.

    shortcutKeyFromEvent keeps event.key only when it is a–z. Everything else in EVENT_CODE_SHORTCUT_KEYS is replaced by the US character for that code:

    https://github.com/pingdotgg/t3code/blob/f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc/apps/web/src/keybindings.ts#L59-L94

    Backslash is hardcoded to \. BracketLeft is [, Quote is ', Semicolon is ;, and the digit row is 0–9. A German ü key (BracketLeft) is recorded as [. The # key is recorded as \.

    Latin letters stay layout-aware. That split landed in #4469. The punctuation table was expanded later in #8103 (2026-09-08), which is what turns this key into \.

    2. Settings and SnapShots both save that string.

    The keybinding editor writes it straight into the draft:

    https://github.com/pingdotgg/t3code/blob/f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc/apps/web/src/components/settings/KeybindingsSettings.logic.ts#L334-L355

    https://github.com/pingdotgg/t3code/blob/f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc/apps/web/src/components/settings/KeybindingsSettings.tsx#L770-L779

    SnapShots call the same function:

    https://github.com/pingdotgg/t3code/blob/f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc/apps/web/src/components/settings/useSnapShotShortcutRecorder.tsx#L109

    The project-script shortcut field does too (projectScriptEditor.tsx). One recorder, three surfaces.

    The capture tests lock this in. Shift plus a key whose layout character is @ or " is saved as mod+shift+2 or mod+shift+', from Digit2 / Quote, not from the character you typed:

    https://github.com/pingdotgg/t3code/blob/f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts#L98-L116

    3. The saved chord still fires on that physical key.

    Runtime matching keeps event.key and also adds the US code alias:

    https://github.com/pingdotgg/t3code/blob/f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc/apps/web/src/keybindings.ts#L96-L109

    So a binding stored as shift+\ matches Shift on the # key, because the code alias is \. The editor is mislabeling the key. It is not dropping the chord. SnapShots then register that stored key with Electron (Shift+\), which is again the US name of the same physical key.

    Shift on that key does not type #. Unshifted is #, Shift types '. The recorder shows neither.

    Not a duplicate

    • #4469 (merged) — letter shortcuts follow the layout. Punctuation was left on the physical map. This report is the punctuation side.
    • #5021 (closed, not merged) — same letter-layout fix. It does not change shortcutKeyFromEvent.
    • #10174 (closed, not merged) — wanted shifted digits stored as 1 rather than !. Same US-physical idea, not this key.
    • #9815 and #12644 — dead-key Backquote handling. The # key is not that key.

    No open issue covers the keybinding or SnapShot recorder replacing layout punctuation with the US code name.

    Fix direction

    Recording and matching should not share one US-only token if the label is supposed to be the key the layout produced.

    Keep event.key when it is a single printable character (#, ', ü, +). Use the code map only as an extra match alias for default chords such as mod+[, which is what resolveEventKeys already does for letters. Today shortcutKeyFromEvent overwrites the layout character before the settings draft is saved, so the file never contains #.

    The capture tests above have to change with that. They currently require the US name.

    Workaround

    The shift+\ shown in the editor is this physical key. Leave it if the chord only needs to fire there. It will not display #.

    A hand-written shift+# in ~/.t3/userdata/keybindings.json does not match Shift on that key: with Shift held, event.key is ' and the code alias is \. The token that matches is shift+\.

    Accepting as a keybinding-recorder bug. SnapShots are the same function, not a second defect.

  3. juliusmarminge removed labelsneeds-triage

  4. juliusmarminge added labelsaccepted

  5. juliusmarminge added labelsvia-triage

  6. Note

    Grok responding on behalf of Julius.

    Fixed by #15972, now on main. The keybinding editor in Settings records the character your layout actually types, so on a German layout Shift plus the # key now shows shift+' instead of shift+\, and unshifted # records #. This should reach the next nightly.

    That PR covers only the Settings keybinding editor. The SnapShot hotkey recorder still records the physical key. If that one still bothers you after updating, please open a separate issue for it.

  7. juliusmarminge closed this

Sign in to join this conversation.