In an iOS app I have (which can also run on an M1 Mac under macOS) there is this routine.
It captures the keystrokes from the DESKTOP keyboard (in mac Mode) as opposed to using the “Virtual Keyboard” for iOS
Anyway this routine returns information I need about the key just pressed, information that so far seems to only be available via this routine.
Now I do KNOW all the “scan” values already, what I DON’T know is the unicode value for each scan value when combined with all the possible modifiers (Shift, alt, cmd, ctrl etc)
I have been trying to find a method that will “simulate” those keypresses, so I can create a table of those values.
I could do it by tediously typing each character and modifier on the actual keyboard, but that is close to 500 combinations
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
guard let key = presses.first?.key else { return }
let scan = "0x"+String(format:"%02x",key.keyCode.rawValue)
let mod = "0x"+String(format:"%08x",key.modifierFlags.rawValue)
let unicode = "0x"+String(format:"%04x",Asc(key.characters))
if unicode != "0x0000" {
print("Scan=[\(scan)] Mod=\(mod) asc=\(unicode) Char=[\(key.characters)]")
}
}