Fix keyboard remapping in password fields and secure input contexts
Some checks failed
Build and Release / Build DMG for arm64 (push) Has been cancelled
Build and Release / Build DMG for x86_64 (push) Has been cancelled
Build and Release / Create Release (push) Has been cancelled

Changed event handling to create and post new keyboard events instead of
modifying existing events, which resolves issues with password fields in
web browsers and other secure input contexts that ignore modified events.

🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
loveuer
2025-12-03 19:07:25 +08:00
parent 333bbc56f9
commit 99bbbbc73a

View File

@@ -38,7 +38,14 @@ class EventTapManager {
if manager.keyMapper.hasMappingFor(keyCode: keyCode) {
if let mappedKey = manager.keyMapper.getMappedKey(for: keyCode) {
Logger.debug("Remapping: \(keyCode) -> \(mappedKey)")
event.setIntegerValueField(.keyboardEventKeycode, value: mappedKey)
let newEvent = CGEvent(keyboardEventSource: nil, virtualKey: CGKeyCode(mappedKey), keyDown: type == .keyDown)
if let newEvent = newEvent {
newEvent.flags = event.flags
newEvent.post(tap: .cghidEventTap)
}
return nil
}
}