Search code examples
iosiphonekeyboard

Programmatically detecting / changing custom keyboards


Is there any way to programmatically detect installed keyboards and/or change the keyboard to a custom keyboard from within your app? As in, if I wanted to show a toolbar above the text keyboard with shortcut buttons to commonly-installed custom keyboards, could I a) detect the keyboard is installed, and b) change to a given keyboard on tap?


Solution

  • This assumes you want the list of keyboards setup in the Settings app under General, Keyboards.

    1. You can determine the primary keyboard:

      UITextInputMode *currentMode = [[UITextInputMode activeInputModes] firstObject];
      
    2. You can determine the possible keyboards

      NSArray *possibleModes = [UITextInputMode activeInputModes];
      
    3. You can determine when the keyboard changes. This is done by listening for the UITextInputCurrentInputModeDidChangeNotification notification.

    4. However, there is no API to change the keyboard.

    So you can do everything you need except the most important part.