swiftipadios-keyboard-extension

Detecting a physical keyboard from a keyboard extension swift ipadOS


i can't seem to find any documentation on how to detect the physical keyboard connection (bluetooth) inside a keyboard extension application. Our keyboard extension is helping children suffering dyslexia how to write. I need to detect if a physical keyboard is attached so i don't show the whole virtual keyboard too. I know it's possible because only one application is doing it perfectly and it's called 'Grammarly'. The only thing i tried so far is overriding the pressesBegan function which is not called in a keyboard extension.

func pressesBegan(_ presses: Set<UIPress>, 
         with event: UIPressesEvent?)

It must be something custom i guess.


Solution

  • You can detect physical keyboard on iOS 14 GameController SDK by using public API GCKeyboard. You just need to import GameController

    let isKeyboardConnected = GCKeyboard.coalesced != nil