PDA

View Full Version : How to check programatically keyboard presense?




sspbond007
Sep 28, 2009, 11:42 PM
Hi,

I need to check condition is keyboard appearing, in my app.

like:

if(keyboardIsPresentOnWindow){
Do action 1;
}else if(keyboardIsPresentOnWindow){
Do action 2;
}

So please help how to check this condition?

Thanks.



skunkworker
Sep 29, 2009, 01:04 AM
Hi,

I need to check condition is keyboard appearing, in my app.

like:

if(keyboardIsPresentOnWindow){
Do action 1;
}else if(keyboardIsPresentOnWindow){
Do action 2;
}

So please help how to check this condition?

Thanks.

Usually the keyboard will be invoked because a textfield or area will become first responder. (pretty much meaning its focused and the keyboard appears). Can you give us some more context in code?

PhoneyDeveloper
Sep 29, 2009, 12:25 PM
When the keyboard appears/disappears a notification is sent. Subscribe to this notification and you'll know if the keyboard is present. Also, the keyboard appears when a textview or textfield is made the first responder. Probably you can query any textfield/view to see if they are the first responder.