app: keybinds match the produced character, so Ctrl+F and other letter shortcuts fail on non-Latin layouts
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- frontend
调研方向
从 packages/app/src/shell/commands/command.tsx 开始,这里有 keyFromKeyboardEvent 和 matchKeybind,并结合同一目录中的快捷键声明一起阅读。在俄语键盘布局下,event.key 是西里尔字符,而 event.code 仍然是 KeyF,因此移除 !event.altKey 条件,让物理按键回退机制覆盖 Ctrl/Meta/Shift,然后映射标点符号的代码(Comma、Period、Semicolon、Quote、BracketLeft、BracketRight、Backslash)。当在非拉丁字母布局下 Ctrl+F 能打开查找栏,列表中的其他绑定也能触发,并且现有的 command 测试全部通过时,即完成。
由索引模型根据 Issue 内容生成。
描述
Description
App keybinds are matched against event.key (the character produced by the active
layout) and only fall back to the physical event.code when Alt is held. On
non-Latin layouts (e.g. Russian) event.key is Cyrillic, so letter and punctuation
shortcuts silently do nothing unless Alt is involved.
Example: the session find bar added in #48470 is bound to mod+f. On an English
layout Ctrl+F opens it; on a Russian layout it does nothing. session.search is
registered with hidden: true, so the command palette cannot reach it either — the
shortcut is the only entry point, and on a Cyrillic layout it never fires.
Root cause — packages/app/src/shell/commands/command.tsx:
export function keyFromKeyboardEvent(event: KeyboardEvent) {
const key = normalizeKey(event.key)
if (!event.altKey || /^[a-z0-9]$/.test(key)) return key
if (!event.code.startsWith("Key") || event.code.length !== 4) return key
return event.code.slice(3).toLowerCase()
}
matchKeybind compares the configured key ("f") with keyFromKeyboardEvent(event).
With a Russian layout, Ctrl+F arrives as event.key === "а", event.code === "KeyF",
event.altKey === false, so the function returns "а" and "f" !== "а" — no match.
Alt+F does match, so the event.code fallback exists but is gated on Alt (it was
added for macOS Option). Ctrl/Meta/Shift on a non-Latin layout are not covered.
The same applies to mod+p, mod+t, mod+w, mod+u, mod+shift+a/e/l/o/r/s/t/x,
mod+shift+d, and the punctuation binds mod+comma, mod+., mod+;, mod+',
mod+[, mod+], mod+\\. Digit binds (mod+1..9) are fine because the digit row
matches across these layouts.
Suggested fix: remove the !event.altKey gate so the physical-key fallback applies to
every modifier (this keeps the macOS Option behavior), and additionally map event.code
for the punctuation keys used in keybinds (Comma, Period, Semicolon, Quote,
BracketLeft, BracketRight, Backslash, …).
Related, but not the same:
- #40048 — "Keybind Ctrl + . does not work with non-US keyboard layouts (e.g., Russian)"
— identical root cause, auto-closed by the stale bot, not fixed. - #6364 — "Hotkeys don't work if the keyboard layout isn't english" — same, auto-closed.
- #54708 — handles
Dead/Unidentifiedkeys; hereevent.keyis a valid character, so
that fallback does not trigger. - #55371 — open, but the TUI (terminal input / Kitty protocol); the app path is separate.
Plugins
None
OpenCode version
2.0.29 (desktop app)
Steps to reproduce
- Open the desktop app on Windows and switch the keyboard layout to Russian (ЙЦУКЕН).
- Open a session and press
Ctrl+Fon the physical F key. → Nothing happens. - Switch to the English layout and press the same physical keys. → The find bar opens.
- Still in the Russian layout,
Alt+Fmatches whileCtrl+Fdoes not.
Screenshot and/or share link
N/A
Operating System
Windows 11 (10.0.22631)
Terminal
N/A — desktop app
- 主要语言
- TypeScript
- 星标
- 221k
- 派生
- 29.6k
- 平均合并
- 5 小时 22 分钟
- 30 天内合并 PR
- 531
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
anomalyco/opencode#59052 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#59040 · 1 条评论 ·
维护者通常 1 天内回复
-
reproduced
难度 2/5 1-3 小时 新手友好度 69/100
anomalyco/opencode#58981 · 2 条评论 ·
维护者通常 1 天内回复
-
triaging
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#58821 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
anomalyco/opencode#58774 · 1 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
ready
难度 2/5 1-3 小时 新手友好度 63/100
wheresrhys/totf#1214 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
CodeChefVIT/ffcs#281 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
endora-commerce/endora-commerce#451 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
vetro-protocol/vetro-monorepo#1007 ·
维护者通常 1 天内回复