Skip to content

fix(tui): resolve keyboard shortcuts failing with non-English IME#21177

Open
MinseongS wants to merge 1 commit intoanomalyco:devfrom
MinseongS:fix/ime-keybind
Open

fix(tui): resolve keyboard shortcuts failing with non-English IME#21177
MinseongS wants to merge 1 commit intoanomalyco:devfrom
MinseongS:fix/ime-keybind

Conversation

@MinseongS
Copy link
Copy Markdown

Issue for this PR

Closes #21163

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

With Korean IME on, all keyboard shortcuts break. Ctrl+C becomes Ctrl+ㅊ, Ctrl+X becomes Ctrl+ㅌ, and so on. I dug into this by adding debug logging to the key event handler and got:

name="ㅊ" ctrl=true baseCode=undefined raw="\x1b[12618;5u" source=kitty

So the terminal sends the Korean character instead of "c", and evt.name === "c" never matches. I also checked if Kitty protocol's baseCode could give us the physical key, but most terminals (VSCode, macOS Terminal) just don't send it.

My fix adds resolveKeyName() in keybind.ts that:

  1. Uses baseCode if the terminal sends it (future-proof)
  2. Falls back to a Korean 2-Set Jamo → QWERTY mapping table
  3. Returns the original name for English/unmapped input

I also updated the hardcoded evt.name === "c" checks in 6 TUI components to go through resolveKeyName().

The mapping table is easy to extend — other layouts just need their entries appended to the same map.

How did you verify your code works?

Built the binary locally and tested with Korean 2-Set IME on macOS. Ctrl+C exits, Ctrl+X opens leader key, normal Korean typing works fine, English shortcuts unchanged. Type check passes.

Screenshots / recordings

N/A — keyboard input change, no visual difference

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

When Korean IME is active, Ctrl+C registers as Ctrl+ㅊ because the
terminal sends the IME-composed character instead of the physical key.
Add IME-to-QWERTY mapping table as fallback when Kitty protocol's
baseCode is unavailable. Other layouts (Russian, Japanese, etc.) can
be added to the same map.

Closes anomalyco#21163
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.

bug(tui): Keyboard shortcuts don't work with Korean IME active

1 participant