AltGr characters fire unmodified hotkeys on the same physical key
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- frontend
调研方向
从 _match.ts 开始:阅读 modifiersMatch(第 86-87 行在 altGraph 下清除 Ctrl/Alt)、第 53 行的拉丁字母守卫、第 60-64 行的 code 回退,以及第 30 行已经处理 Ctrl/Alt 热键的直接 key 路径。决定 AltGr 产生的字符应在何处跳过物理按键回退,然后运行包的测试套件以及 issue 中的三个复现案例(它们都应返回 false)。完成的标志是 AltGr 按键不再匹配,同时现有的热键匹配测试仍然通过。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
On layouts with AltGr (German, Polish, …), typing an AltGr character fires an unmodified single-key hotkey on the same physical key.
- German AltGr+M types
µand fires aMhotkey. - Polish AltGr+C types
ćand fires aChotkey. - German AltGr+Q types
@and fires aQhotkey.
In _match.ts, modifiersMatch clears Ctrl and Alt when altGraph is set (lines 86–87). The code fallback (lines 60–64) then maps KeyM → M, which matches. For ć, the Latin-letter guard at line 53 is skipped because normalized.alt is true under AltGr. µ and @ aren't Latin letters, so the guard doesn't apply at all.
Reproduce
import { matchesKeyboardEvent } from '@tanstack/hotkeys'
// What Chrome on Windows reports for AltGr+<key>: Ctrl+Alt plus the AltGraph modifier state.
const altGr = (key: string, code: string) =>
({ type: 'keydown', key, code, ctrlKey: true, altKey: true, shiftKey: false, metaKey: false,
isComposing: false, getModifierState: (k: string) => k === 'AltGraph' }) as unknown as KeyboardEvent
matchesKeyboardEvent(altGr('µ', 'KeyM'), 'M', 'windows') // true, expected false
matchesKeyboardEvent(altGr('ć', 'KeyC'), 'C', 'windows') // true, expected false
matchesKeyboardEvent(altGr('@', 'KeyQ'), 'Q', 'windows') // true, expected false
Expected
A key press that produced a character through AltGr is text input and should not fall back to the physical key. Only a direct key match should count, as line 30 already does for hotkeys with Ctrl/Alt.
Versions
@tanstack/hotkeys 0.11.0 and @tanstack/react-hotkeys 0.13.0. _match.ts on main still has the same code.
- 主要语言
- TypeScript
- 星标
- 744
- 派生
- 49
- 平均合并
- 1 天 16 小时
- 30 天内合并 PR
- 30
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/hotkeys 的其他 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
polarsource/polar#15580 ·
维护者通常 1 天内回复
-
accepted bug via-triage
难度 2/5 1-3 小时 新手友好度 69/100
pingdotgg/t3code#20931 · 1 条评论 ·
维护者通常 1 天内回复
-
bug/1-unconfirmed kind/bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
-
难度 2/5 1-3 小时 新手友好度 72/100
ranxianglei/billion-context#3583 ·
维护者通常 1 天内回复