Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

app: keybinds match the produced character, so Ctrl+F and other letter shortcuts fail on non-Latin layouts

未关闭 适合新手
#55,676 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@ZXLyyds100 已经在做这个了。

开始于 2026年10月15日。

  • #55765 来自 @ZXLyyds100 —— 未关闭

评估

难度
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 内容生成。

描述

reproduced
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/Unidentified keys; here event.key is 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
  1. Open the desktop app on Windows and switch the keyboard layout to Russian (ЙЦУКЕН).
  2. Open a session and press Ctrl+F on the physical F key. → Nothing happens.
  3. Switch to the English layout and press the same physical keys. → The find bar opens.
  4. Still in the Russian layout, Alt+F matches while Ctrl+F does 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。