I am porting an iOS app on MacOS using UIKit for Mac also known as iPad Apps for Mac or Project Catalyst.
The app uses keyCommands
from UIKit
to detect a single modifier key press:
UIKeyCommand(input: "", modifierFlags: .shift, action: #selector(singleShift))
This code works perfectly on iPad with an external keyboard, I am getting the event fired with every single ⇧ press. However, this does not work on MacOS, although single non-modifier events and modifier + non-modifier combinations work.
How do I achieve the desired behavior and get notified about single modifier key events?
Or maybe I should just give up on UIKeyCommand
and try UIGestureRecognizer
instead?
This may not be your problem make sure you don't have any keyboard apps or apps that intercept keyboard input running. I had a problem like this when I had Karibeaner-elements installed.
Otherwise, if this is a limitation of catalyst consider wrapping a more stable API from app kit or use UIGestureRecognizer
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With