0
votes

I would like to somehow hide the keyboard shown in iOS whenever I focus in a textfield.

When I say "focus", I would still like to be able to type in stuff from an external keyboard, but the iOS virtual keyboard should not be displayed.

Stuff from previous SO questions which are not applicable:

  • [textfield resignFirstResponder] --> hides the iOS keyboard but cannot take input events from external keyboard anymore.
  • [view endEditing: YES] --> does not work. sSame as above.
  • javascript onblur() outoffocus not applicable.

Does anybody out there know a way to just hide the keyboard but still listen to key events?

1

1 Answers

0
votes

I'll answer my own question here, if in case anybody stumbles on a similar dilemma.

Most of the answers out there involve losing focus from a textfiled or resigning the first responder. However when this is not an option as in my case where i want to listen to keyboard event in iOS webview

All you have to do is implement UIKeyInput in your view controller. Now as soon as you do this, the keyboard show up. No to make the keyboard disappear, just reimplement a custom keyboard view with 0 height.

If you want the keyboard to appear as soon as you transition to a different screen, you can resign the firstreponder as soon as you leave the screen and return nil for the UIView instead of keyboard view.