views:

77

answers:

2

Hey Everyone,

Does anyone know of a way to utilize the iPhone's hardware keyboard with something other than a UITextView/Field, basically I want to be able to send characters pressed on the virtual keyboard to my own view. If anyone can help me out that'd be immensely appreciated!!

A: 

You could place a hidden UITextField off screen, and tell it to becomeFirstResponder this will show the keyboard.

Then you can listen for the text did change notification that the text field posts and do what you need in there.

The notification is posted whenever a key is tapped, including the delete key.

Jasarien
A: 

I've done this by using a hidden text field. Not incredibly elegant but it works, basically on whatever event you want to show the keyboard for you call

[myHiddenTextField becomeFirstResponder];

then monitor the input using the text field's text property, register for the event to let you know when something has been typed

[myHiddenTextField addTarget:self action:@selector(processKeyboardInput:) forControlEvents:UIControlEventEditingChanged];
mbehan
What about memory/cpu usage? Is it noticeable?
Adam
I've not noticed any performance issues with it in my app, so have never dug into the figures with instruments or anything. What you do in the processKeyboardInput method will likely have the biggest impact.
mbehan