From 99bbbbc73ad389a43e5e802649c6b09d7acce807 Mon Sep 17 00:00:00 2001 From: loveuer Date: Wed, 3 Dec 2025 19:07:25 +0800 Subject: [PATCH] Fix keyboard remapping in password fields and secure input contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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] --- Sources/EventTapManager.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/EventTapManager.swift b/Sources/EventTapManager.swift index d5d4abb..5fb297a 100644 --- a/Sources/EventTapManager.swift +++ b/Sources/EventTapManager.swift @@ -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 } }