Is there a way to detect if an external (bluetooth or usb) keyboard is connected to the iPad?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An indirect and SDK-safe way is to make a text field a first responder. If the external keyboard is present, the
UIKeyboardWillShowNotificationlocal notification shall not be posted.You can listen to the
"GSEventHardwareKeyboardAttached"(kGSEventHardwareKeyboardAvailabilityChangedNotification) Darwin notification, but this is a private API, so it’s possible your app will get rejected if you use this. To check if the external hardware is present, use the privateGSEventIsHardwareKeyboardAttached()function.UIKit listens to this and sets the
UIKeyboardImpl.isInHardwareKeyboardModeproperty accordingly, but again this is private API.