Previous to iOS 9, the most reliable method of determining whether an external keyboard is connected was to listen for UIKeyboardWillShowNotification and make a
UIKeyboardWillShowNotification
iOS 14 SDK finally brings public API for that: GCKeyboard. To check if external keyboard is connected:
GCKeyboard
let isKeyboardConnected = GCKeyboard.coalescedKeyboard != nil
Notes:
import GameController
if #available(iOS 14.0, *)