fix: consume hotkey events to prevent character key leak#59
Merged
hehehai merged 2 commits intohehehai:mainfrom May 6, 2026
Merged
fix: consume hotkey events to prevent character key leak#59hehehai merged 2 commits intohehehai:mainfrom
hehehai merged 2 commits intohehehai:mainfrom
Conversation
When a non-modifier hotkey combo (e.g. Fn+Space, Fn+Z) is pressed, the character key event was passed through to the foreground app, causing unwanted text insertion. Change the CGEvent tap from listen-only to an active tap that returns nil (consumes the event) when a non-modifier keyDown/keyUp matches a configured hotkey. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Owner
|
这次补充提交主要处理了 hotkey active tap 引入后的事件消费回归,并顺带把 ESC 取消链路一起收紧。 本次修改和优化:
补充测试:
本地验证: xcodebuild test -project Voxt.xcodeproj -scheme Voxt -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO -only-testing:VoxtTests/HotkeyManagerTests已通过,结果为 另外也用 Xcode 运行中的 Dev App 做了手动回归:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
当用户按下不含修饰键的快捷键组合(例如 Fn+Space、Fn+Z)时,字符键事件会穿透到前台应用,导致当前输入框中意外插入字符。
例如:在文本编辑器中,按下快捷键
Fn+Space本来应该触发语音转文字,但结果是在编辑器里插入了一个空格。解决方案
将
CGEventTap从仅监听模式(listen-only)改为活动模式(active tap):keyDown/keyUp)被触发时,返回nil来消费该事件,阻止其继续传递到前台应用。修复效果
测试计划
xcodebuild test -project Voxt.xcodeproj -scheme Voxt -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO -only-testing:VoxtTests/HotkeyManagerTests— 全部 23 项测试通过