For some reason I can't get hardware keyboard shortcuts to work in iPadOS 15 (beta 5). They work for most keys, but not for arrow keys and tab key.
The same code seems to work well when compiled in Xcode 13 (beta 4) and run on iPadOS 14.5 simulator, but then refuses to work when built with same Xcode but on iPadOS 15 sim. I've tried it on actual devices with iPadOS 15 betas up to 5 with same results.
Here is a minimal example:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
addKeyCommand(UIKeyCommand(title: "UP", action: #selector(handle(key:)), input: UIKeyCommand.inputUpArrow, modifierFlags: []))
addKeyCommand(UIKeyCommand(title: "DOWN", action: #selector(handle(key:)), input: UIKeyCommand.inputDownArrow, modifierFlags: []))
addKeyCommand(UIKeyCommand(title: "TAB", action: #selector(handle(key:)), input: "\t", modifierFlags: []))
}
@objc func handle(key: UIKeyCommand?) {
NSLog("Intercepted key: \(key?.title ?? "Unknown")")
}
}
I haven't found any related reports or open radars, so I'm suspecting I could be missing something here. If this should be reported, where do I report a bug like that?
Thank you.
Apparently, there is a new
UIKeyCommand
propertywantsPriorityOverSystemBehavior
, which needs to be set totrue
for some keys — like the ones I mentioned in my question: https://developer.apple.com/documentation/uikit/uikeycommand/3780513-wantspriorityoversystembehavior