Previous to iOS 9, the most reliable method of determining whether an external keyboard is connected was to listen for UIKeyboardWillShowNotification and make a
If you make the toolbar irrelevant then the keyboard doesn't show up. Do this by blanking out its left and right groups (at least on iOS 12.4):
textField.inputAssistantItem.leadingBarButtonGroups = []
textField.inputAssistantItem.trailingBarButtonGroups = []
...and in case it helps here is a swifty way to observe:
// Watch for a soft keyboard to show up
let observer = NotificationCenter.default.addObserver(forName: UIWindow.keyboardWillShowNotification, object: nil, queue: nil) { notification in
print("no external keyboard")
}
// Stop observing shortly after, since the keyboard should have shown by now
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
NotificationCenter.default.removeObserver(observer)
}