Skip to content

fix: resolve JIS keyboard bracket and backslash shortcut mapping - #2624

Merged
Jinwoo-H merged 2 commits into
stablyai:mainfrom
octu0:fix/jis-keyboard-bracket-shortcuts
May 22, 2026
Merged

Jinwoo-H merged 2 commits into
stablyai:mainfrom
octu0:fix/jis-keyboard-bracket-shortcuts

Conversation

@octu0

@octu0 octu0 commented May 22, 2026

Copy link
Copy Markdown
Contributor

Note

Please note that since English is not my native language, the text below was generated using AI translation.
If there is anything you don't understand, please let me know and I will clarify.

Summary

Fixes an issue where bracket shortcuts (Cmd+Shift+[ and Cmd+Shift+]) do not work correctly on JIS (Japanese) keyboard layouts, specifically when attempting to switch tabs or split panes.

Problem:
On a JIS keyboard, the physical keys for [ and ] emit different KeyboardEvent.code values compared to a US QWERTY layout:

  • [ emits BracketRight
  • ] emits Backslash

Because the keybinding matcher in src/shared/keybindings.ts relied strictly on event.code to resolve BracketLeft, BracketRight, and Backslash, JIS users pressing Cmd+Shift+[ were triggering the BracketRight action (Next Tab), and pressing Cmd+Shift+] was triggering Backslash (which resulted in a no-op or unintended behavior).

Solution:
Updated the keybinding resolution logic in src/shared/keybindings.ts to also evaluate the event.key property when dealing with brackets and backslashes. By checking the actual character inputted ([, {, ], }, \, |), we can reliably determine the user's intent across international keyboard layouts, while still falling back to event.code for physical position mapping.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed
    • Added dedicated unit tests in src/shared/keybindings.test.ts to verify JIS shifted key combinations correctly map to the expected bracket actions and do not falsely trigger backslash/opposite brackets.

AI Review Report

The AI agent reviewed the keyboard shortcut matching logic. The main risk checked was ensuring that fallback checks on the event.key property would not inadvertently break US/UK layouts or create cross-platform conflicts.

  • Verified that adding event.key checks strictly scopes to characters outputted by those specific keys.
  • Added explicit exclusionary checks (e.g. if (key === ']' || key === '}') { return false } inside BracketLeft) to ensure that if a JIS layout emits BracketRight for the [ key, it doesn't accidentally trigger both shortcuts simultaneously.
  • Full local build, typecheck, and unit tests have verified the safety of this change.

Security Audit

No security implications. This PR only modifies local keyboard event matching logic in the shared layer. No IPC boundary changes, no command execution, and no dependency changes.

Notes

  • Platform Specifics: This specifically resolves a friction point for Japanese macOS/Windows users using JIS keyboards, but the fallback logic also improves shortcut resilience for other international ISO layouts (like German QWERTZ or French AZERTY) that rely on AltGr combinations to type brackets.

JIS keyboards emit different event.code for bracket keys compared to US layouts. BracketRight is emitted for '[', and Backslash for ']'. This commit updates the keybinding matcher to also evaluate the 'key' property to reliably identify brackets and backslash across different keyboard layouts.
@AmethystLiang
AmethystLiang requested a review from Jinwoo-H May 22, 2026 17:48
- centralize semantic bracket/backslash matching for international layouts

- preserve physical-code fallback when key text is inconclusive

- avoid stealing AltGr bracket input on Windows/Linux

- expand regression coverage for tab, pane, and fallback behavior

Co-authored-by: Orca <[email protected]>
@Jinwoo-H
Jinwoo-H merged commit ff469bf into stablyai:main May 22, 2026
1 check passed
@nwparker

Copy link
Copy Markdown
Contributor

Thank you @octu0 !

@octu0

octu0 commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

😃

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…blyai#2624)

Fix JIS bracket/backslash shortcut intent matching across tab and terminal-pane shortcuts.\n\nReview follow-up:\n- centralize semantic punctuation matching for bracket/backslash keys\n- preserve physical-code fallback when key text is inconclusive\n- avoid stealing AltGr bracket input on Windows/Linux\n- add regression coverage for JIS, AltGr, and fallback behavior
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.

3 participants