[PR #6753] feat(keybinds): support physical keycode-based keybindings for non-English layouts #12084

Open
opened 2026-02-16 18:17:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6753

State: open
Merged: No


feat: Support physical keycode-based keybindings for non-English keyboard layouts

Summary

Add support for physical key position matching in keybindings, enabling shortcuts to work correctly with non-English keyboard layouts (Korean, Japanese, Chinese, AZERTY, Dvorak, etc.).

Problem

When using non-English input methods, keybindings fail because OpenCode matches by character name:

  • User configures ctrl+x
  • In Korean mode, Ctrl + X key produces ctrl+ㅌ
  • Keybind doesn't match → shortcut fails

Solution

Leverage OpenTUI's existing Kitty keyboard protocol support (baseCode field) for physical key matching.

Changes

File Change
src/util/keybind.ts Add baseCode to Info type, update match() with MatchOptions
src/cli/cmd/tui/context/keybind.tsx Pass usePhysicalKeys config to match()
src/config/config.ts Add usePhysicalKeys keybind option
test/keybind.test.ts Add 18 tests for physical key matching

Usage

{
  "keybinds": {
    "usePhysicalKeys": true
  }
}

Compatibility

  • Opt-in: Default false for backward compatibility
  • Graceful fallback: Falls back to character matching when baseCode unavailable
  • Terminal support: Works with Kitty, Ghostty, WezTerm, iTerm2, Alacritty

Testing

Added tests for:

  • Physical key matching with Korean input (한글)
  • AZERTY layout simulation
  • Fallback behavior
  • Modifier key handling with physical keys
  • Leader key combinations

Related

  • Closes #XXXX (if issue exists)
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6753 **State:** open **Merged:** No --- # feat: Support physical keycode-based keybindings for non-English keyboard layouts ## Summary Add support for physical key position matching in keybindings, enabling shortcuts to work correctly with non-English keyboard layouts (Korean, Japanese, Chinese, AZERTY, Dvorak, etc.). ## Problem When using non-English input methods, keybindings fail because OpenCode matches by character name: - User configures `ctrl+x` - In Korean mode, `Ctrl + X key` produces `ctrl+ㅌ` - Keybind doesn't match → shortcut fails ## Solution Leverage OpenTUI's existing Kitty keyboard protocol support (`baseCode` field) for physical key matching. ### Changes | File | Change | |------|--------| | `src/util/keybind.ts` | Add `baseCode` to `Info` type, update `match()` with `MatchOptions` | | `src/cli/cmd/tui/context/keybind.tsx` | Pass `usePhysicalKeys` config to `match()` | | `src/config/config.ts` | Add `usePhysicalKeys` keybind option | | `test/keybind.test.ts` | Add 18 tests for physical key matching | ### Usage ```json { "keybinds": { "usePhysicalKeys": true } } ``` ### Compatibility - **Opt-in**: Default `false` for backward compatibility - **Graceful fallback**: Falls back to character matching when `baseCode` unavailable - **Terminal support**: Works with Kitty, Ghostty, WezTerm, iTerm2, Alacritty ## Testing Added tests for: - Physical key matching with Korean input (한글) - AZERTY layout simulation - Fallback behavior - Modifier key handling with physical keys - Leader key combinations ## Related - Closes #XXXX (if issue exists)
yindo added the pull-request label 2026-02-16 18:17:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12084