Search code examples
iosswiftuitextview

Make a new line when hitting the Return key on a physical iPad keyboard SwiftUI


I'm having trouble creating a new line on a TextField when the iPad physical keyboard is attached, any idea on how to achieve this?

My code is as follows:

TextField("Message", text: $messageToSend, axis: .vertical)
                    .focused($editing)

So when I don't have the physical keyboard attached, it creates new lines and grows vertically (everything works great) but as soon as I attach the physical keyboard the return button will only resign my TextField.


Solution

  • Well after the first comment, I realised that for the iPad physical keyboard option + return does the trick.