diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95b71d8..fd4fe77 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,11 @@ All notable changes to OpenWritr will be documented in this file.
Each release's notes on GitHub are generated from its section here, and the
broker publication handoff fails when the section for a tag is missing or empty.
+## [1.7.5] — 2026-10-29
+
+### Fixed
+- Typing into Windows App (**Type Text in Remote Desktop Apps**) now produces shifted characters correctly. OpenWritr's simulated Shift key did not mark which Shift key was pressed, so the remote PC could receive the unshifted key instead: on a German layout `?` arrived as `ß`. Shift is now sent as the left Shift key, like a real key press
+
## [1.7.4] — 2026-10-13
### Fixed
diff --git a/Info.plist b/Info.plist
index 2617189..253524c 100644
--- a/Info.plist
+++ b/Info.plist
@@ -7,9 +7,9 @@
CFBundleIdentifier
com.openwritr.app
CFBundleVersion
- 1.7.4
+ 1.7.5
CFBundleShortVersionString
- 1.7.4
+ 1.7.5
NSHumanReadableCopyright
Copyright © 2026 Torsten Mahr. Released under the MIT License.
OpenWritrDescription
diff --git a/Sources/OpenWritr/TextTyping.swift b/Sources/OpenWritr/TextTyping.swift
index d828c89..4908a1f 100644
--- a/Sources/OpenWritr/TextTyping.swift
+++ b/Sources/OpenWritr/TextTyping.swift
@@ -1,6 +1,7 @@
import Carbon.HIToolbox
import Cocoa
import CoreGraphics
+import IOKit.hidsystem
import os.log
private let typingLog = Logger(subsystem: "com.openwritr.app", category: "TextTyping")
@@ -208,6 +209,10 @@ enum TypingDelivery {
struct SystemTextTyper: TextTyping {
private static let shiftKeyCode: CGKeyCode = 0x38
+ // Remote clients can track left/right modifiers using the device-dependent flags.
+ private static let shiftFlags = CGEventFlags.maskShift.union(
+ CGEventFlags(rawValue: UInt64(NX_DEVICELSHIFTKEYMASK))
+ )
/// Remote desktop clients can drop key events that arrive faster than they are forwarded.
private nonisolated static let eventSpacing: useconds_t = 3_000
private nonisolated static let queue = DispatchQueue(label: "com.openwritr.text-typing")
@@ -255,11 +260,11 @@ struct SystemTextTyper: TextTyping {
}
}
- private static func eventGroups(for strokes: [KeyStroke], source: CGEventSource) -> [[CGEvent]]? {
+ static func eventGroups(for strokes: [KeyStroke], source: CGEventSource) -> [[CGEvent]]? {
var groups: [[CGEvent]] = []
for stroke in strokes {
var events: [CGEvent] = []
- let flags: CGEventFlags = stroke.shift ? .maskShift : []
+ let flags: CGEventFlags = stroke.shift ? shiftFlags : []
if stroke.shift {
guard let shiftDown = modifierEvent(source: source, down: true) else { return nil }
events.append(shiftDown)
@@ -283,10 +288,10 @@ struct SystemTextTyper: TextTyping {
/// Shift is sent as a real modifier key event, because a remote desktop client tracks modifier
/// changes rather than trusting the flags of a key event.
private static func modifierEvent(source: CGEventSource, down: Bool) -> CGEvent? {
- guard let event = CGEvent(source: source) else { return nil }
+ guard let event = CGEvent(keyboardEventSource: source, virtualKey: shiftKeyCode, keyDown: down)
+ else { return nil }
event.type = .flagsChanged
- event.setIntegerValueField(.keyboardEventKeycode, value: Int64(shiftKeyCode))
- event.flags = down ? .maskShift : []
+ event.flags = down ? shiftFlags : []
return event
}
}
diff --git a/Tests/OpenWritrTests/TextTypingTests.swift b/Tests/OpenWritrTests/TextTypingTests.swift
index f1906bd..8b537ae 100644
--- a/Tests/OpenWritrTests/TextTypingTests.swift
+++ b/Tests/OpenWritrTests/TextTypingTests.swift
@@ -129,6 +129,41 @@ struct TextTypingPlanTests {
}
}
+@MainActor
+@Suite("Remote keyboard events")
+struct RemoteKeyboardEventTests {
+ @Test func germanQuestionMarkAndCapitalsCarryLeftShiftUntilKeyRelease() throws {
+ let layout: [Character: KeyStroke] = [
+ "?": KeyStroke(keyCode: 0x1B, shift: true),
+ "ß": KeyStroke(keyCode: 0x1B, shift: false),
+ "A": KeyStroke(keyCode: 0, shift: true),
+ "a": KeyStroke(keyCode: 0, shift: false),
+ ]
+ let plan = TextTypingPlanner.plan(for: "?ßAa", layout: layout)
+ let source = try #require(CGEventSource(stateID: .privateState))
+ let groups = try #require(SystemTextTyper.eventGroups(for: plan.strokes, source: source))
+
+ #expect(groups.count == 4)
+ for index in [0, 2] {
+ let events = groups[index]
+ #expect(events.map(\.type) == [.flagsChanged, .keyDown, .keyUp, .flagsChanged])
+ #expect(events.map { $0.getIntegerValueField(.keyboardEventKeycode) } == [
+ 0x38, Int64(plan.strokes[index].keyCode), Int64(plan.strokes[index].keyCode), 0x38,
+ ])
+ for event in events.prefix(3) {
+ #expect(event.flags.contains(.maskShift))
+ #expect(event.flags.rawValue & 0x00000002 != 0, "The left Shift flag must reach the remote client")
+ #expect(event.flags.rawValue & 0x00000004 == 0, "Right Shift is not pressed")
+ }
+ #expect(events[3].flags.isEmpty, "Release Shift after the character's key-up")
+ }
+ for index in [1, 3] {
+ #expect(groups[index].map(\.type) == [.keyDown, .keyUp])
+ #expect(groups[index].allSatisfy { $0.flags.isEmpty })
+ }
+ }
+}
+
@MainActor
@Suite("System keyboard layout")
struct SystemKeyboardLayoutTests {