Can pressesBegan be used to simulate text input in a UITextView?

Hi,

I’m working with custom text input handling in a UITextView. For simulating user typing programmatically, the documented way is to call:

textView.insertText("H")

This correctly inserts text, triggers delegate callbacks, updates the caret, and behaves as expected.

However, since physical keyboard input normally goes through pressesBegan(:with:) before being translated into insertText(:), I was wondering:

Is it possible (or supported) to call pressesBegan ourselves with a constructed UIPress/UIKey to simulate key input events in the same way the system does?

Or

Is the intended approach strictly to use insertText(_:) for simulating text entry, and pressesBegan should only ever be used for listening to actual hardware key presses?

Thanks!

Can pressesBegan be used to simulate text input in a UITextView?
 
 
Q