Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get keyboard input without a text field/view

I'm making an iPhone application that has my own custom text view that can display multi-formatted text and I need to interact with the keyboard somehow. Right now I am using a hidden UITextField and the delegate method textField:shouldChangeCharactersInRange:replacementString: to get the typed characters. However this feels kludgy and I was wondering if it's possible to show the keyboard and get notified of each key tap without using a UITextField or UITextView?

Thanks,

Kyle

like image 969
Kyle Avatar asked May 07 '09 04:05

Kyle


People also ask

How to define keyboard input in HTML5?

- GeeksforGeeks How to define keyboard input in HTML5 ? The phrase tag is used to define the keyboard input. The text enclosed by <kbd> tag is typically displayed in the browser’s default monospace font. In this article, we define the keyboard input by using various types of tags like <kbd>, <code>, <em>, <var>, and <samp>. Keyboard input.

How to submit data if text field is empty?

Add an IF() to the DisplayMode of the button you are using to submit the data. If the textfield is empty then set display mode of the button to disabled and if its not set it to Edit. Until the user fills in the text field they won't be able to submit, so it will be required. If I have answered your question, please mark your post as Solved.

How do I know which keyboard type to use in iOS?

In iOS, iPadOS, and tvOS apps, show the appropriate keyboard type. Several different keyboard types are available, each designed to facilitate a different type of input. To streamline data entry, the keyboard you display when editing a text view should be appropriate for the type of content.

How to show keypad above textinput widget on focus?

By default if we do not use KeyboardAvoidingView then Keypad will show above TextInput widget on focus. But when we use KeyboardAvoidingView then it will slightly push the TextInput above from screen and show Keypad just below the selected TextInput component.


2 Answers

The documentation for the UIKeyInput protocol says the following:

A subclass of UIResponder can adopt this protocol to implement simple text entry. When instances of this subclass are the first responder, the system keyboard is displayed.

Only a small subset of the available keyboards and languages are available to classes that adopt this protocol.

So this might serve your needs better than a hidden text field/view.

like image 132
Kristopher Johnson Avatar answered Oct 11 '22 00:10

Kristopher Johnson


In the public API, the best you can do is as you described. UIKeyboard and UIKeyboardImpl are both private unfortunately.

like image 35
rpetrich Avatar answered Oct 11 '22 02:10

rpetrich