Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

fix: use layout-aware key resolution for all printable keys, not just missing ones

Paul Somers4b597ad678c5
diff --git a/Sources/Fluid/Models/HotkeyShortcut.swift b/Sources/Fluid/Models/HotkeyShortcut.swift
index 86856138..394a7d37 100644
--- a/Sources/Fluid/Models/HotkeyShortcut.swift
+++ b/Sources/Fluid/Models/HotkeyShortcut.swift
@@ -14,13 +14,7 @@ struct HotkeyShortcut: Codable, Equatable {
if self.modifierFlags.contains(.option) { parts.append("⌥") }
if self.modifierFlags.contains(.control) { parts.append("⌃") }
if self.modifierFlags.contains(.shift) { parts.append("⇧") }
- if let key = Self.keyCodeToString(keyCode) {
- parts.append(key)
- } else if let key = Self.characterForKeyCode(keyCode) {
- parts.append(key)
- } else {
- parts.append("?")
- }
+ parts.append(Self.keyCodeToString(keyCode) ?? "?")
if self.modifierFlags.isEmpty {
return parts.last ?? "Unknown"
@@ -49,60 +43,12 @@ struct HotkeyShortcut: Codable, Equatable {
case 124: return "Right"
case 125: return "Down"
case 126: return "Up"
- case 0: return "A"
- case 1: return "S"
- case 2: return "D"
- case 3: return "F"
- case 4: return "H"
- case 5: return "G"
- case 6: return "Z"
- case 7: return "X"
- case 8: return "C"
- case 9: return "V"
- case 10: return "§"
- case 11: return "B"
- case 12: return "Q"
- case 13: return "W"
- case 14: return "E"
- case 15: return "R"
- case 16: return "Y"
- case 17: return "T"
- case 31: return "O"
- case 32: return "U"
- case 34: return "I"
- case 35: return "P"
- case 37: return "L"
- case 38: return "J"
- case 40: return "K"
- case 45: return "N"
- case 46: return "M"
- case 18: return "1"
- case 19: return "2"
- case 20: return "3"
- case 21: return "4"
- case 23: return "5"
- case 22: return "6"
- case 26: return "7"
- case 28: return "8"
- case 25: return "9"
- case 29: return "0"
- case 24: return "="
- case 27: return "-"
- case 33: return "["
- case 30: return "]"
- case 41: return ";"
- case 39: return "'"
- case 42: return "\\"
- case 43: return ","
- case 47: return "."
- case 44: return "/"
- case 50: return "`"
- default: return nil
+ default: return characterForKeyCode(keyCode)
}
}
/// Uses the current keyboard layout to resolve a key code to its displayed character.
- private static func characterForKeyCode(_ keyCode: UInt16) -> String? {
+ static func characterForKeyCode(_ keyCode: UInt16) -> String? {
guard let sourceRef = TISCopyCurrentKeyboardLayoutInputSource()?.takeRetainedValue(),
let rawPtr = TISGetInputSourceProperty(sourceRef, kTISPropertyUnicodeKeyLayoutData)
else { return nil }