SwiftUI TextEdit iPad external keyboard "Return" key

I can intercept the "Return" button and "Shift+Return" on an iPad's external Bluetooth keyboard with the TextField "onKeyPress" method. But - this always dismisses the keyboard. It looks like the TextField loses focus. This happens whether I return ".handled" or ".ignored".

How can I maintain focus on the TextField and not have the keyboard dismissed?

this always dismisses the keyboard. It looks like the TextField loses focus.

Since you mentioned "external Bluetooth keyboard", I am wondering what you meant about the keyboard being dismissed...

Did you mean that when you use the system-provided virtual keyboard and hit the Return key, the virtual keyboard is dismissed? If that is the case, is switching to TextEditor an option for you? I think that may be the easiest option to implement multiple line text input on iOS / iPadOS.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

SwiftUI TextEdit iPad external keyboard "Return" key
 
 
Q