Hi everyone,
In UIKit, I can detect which key and modifier keys are pressed from an external hardware keyboard using the pressesBegan method in a UIResponder:
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
for press in presses {
if let key = press.key {
print("Key: \(key.charactersIgnoringModifiers ?? "")")
print("Modifiers: \(key.modifierFlags)")
}
}
}
I am now working in SwiftUI (iOS), and I couldn’t find a direct equivalent for pressesBegan.
What is the recommended way in SwiftUI to detect modifier keys + key presses from an external keyboard? Is there a built-in API, or should I always wrap a UIKit view/controller for this purpose?
Thanks in advance!