How to make the return key appear on numeric keyboards?

I have a UITextField object in a storyboard's scene where the user is make numeric entries. Because this field is for numbers only I set the keyboard type to "Number Pad" in attributes. But this keyboard does not have a return key which leaves the user unable to signal when the entry is complete, the keyboard should be put away, and the entered value processed. I tried all the other numeric keyboards also, and found that none of them has a return key. The default keyboard does, but it is a full alphanumeric keyboard which is undesirable for that field.

How can I cause the return key, done key, or whichever does that function, appear on a numeric only keyboard?

Accepted Reply

That's an old issue. Really a pity as there is room for a return key.

There are at least 2 options:

  • add a subview in the keyboard, but it's hard to position correctly and has some side effects
  • add a close button above, in the toolbar

https://stackoverflow.com/questions/45207879/how-to-add-uibarbuttonitem-to-right-side-of-uitoolbar

https://stackoverflow.com/questions/38577435/swift-programmatically-add-uibutton-above-keyboard

Replies

That's an old issue. Really a pity as there is room for a return key.

There are at least 2 options:

  • add a subview in the keyboard, but it's hard to position correctly and has some side effects
  • add a close button above, in the toolbar

https://stackoverflow.com/questions/45207879/how-to-add-uibarbuttonitem-to-right-side-of-uitoolbar

https://stackoverflow.com/questions/38577435/swift-programmatically-add-uibutton-above-keyboard

add a subview in the keyboard, but it's hard to position correctly and has some side effects

And note that in iOS 17, the keyboard runs outside your process. (See WWDC video Keep up with the keyboard.) So the unsupported technique of adding subviews to the keyboard may not even work at all any more.