How can I call a method when a key is typed?
Is there a way to call a method each time a user types on the onscreen keyboard? For example, a method is called when the user always hits the w key and a differe开发者_JAVA技巧nt method for the s key. Or will I need to create my own keyboard for the user to use?
This will be for the iPad.
First create a subclass of UIResponder
(e.g. a UIView
or UIViewController
) and have it adopt the UIKeyInput
protocol (and implement the required methods). Then make it first responder. The method insertText:
will be called for each key.
Caveat: Not all keyboards are supported (e.g. Japanese, Simplified Chinese).
精彩评论