Conflict with UIKeyInput protocol

I would like to catch the key-in event with pressesBegan. But any normal text events does not reach pressesBegan.
Instead, I get this message in the debugger screen : "Warning: insertText reached".

I implemented UIKeyInput protocol at my UIViewController and seemed that I could catch the events via insertText.

But not possible to handle key up/down events via this protocol.

Is there any best practice to handle normal text key-in/out events?




Replies

Forgot to write the context I am facing.

I am building my iOS app for mac (Catalyst). Please imagine vim like input. When you hit {fghj}, you can move a symbol. This is not "commands", so I do not want to implement as "UIKeyCommand".

Of course this behavior hopefully works with iPadOS with an external keyboard.

Use:
  • (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event

  • (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event