JavaScript to launch Android system keyboard selector?

Is it possible to use JavaScript embedded in an Android keyboard to open the Android system keyboard switcher? While devices with virtual navigation buttons in the main screen usually show an icon there for switching keyboards (when a keyboard is active), many devices require the user to find the keyboard switcher among the notifications, which can be a slow process, just to go type a phrase in another script.
Due to high multilingualism, users of my standalone keyboard would often need to switch from this vernacular keyboard to Arabic and English system keyboards.

I understand you’d like to make it easier for your keyboard users to switch between Android system keyboards. If your standalone keyboard only uses a single Keyman keyboard, you could change the globe key to advance to the next system keyboard.

The Keyman Engine for Android call (in Java) is

KMManager.setGlobeKeyAction(KeyboardType.KEYBOARD_TYPE_SYSTEM, 
   GlobeKeyAction.GLOBE_KEY_ACTION_ADVANCE_TO_NEXT_SYSTEM_KEYBOARD);

See reference

Note: you’ll need to get the latest Keyman engine due to a recent bug fix
https://downloads.keyman.com/android/stable/13.0.6213/

Is there any documentation or are there examples on where to put that code?

That was going to be my next question, too. So far, my standalone keyboard app is built with KAB. I suspect I’d have to start over from scratch to implement this. (If only KAB would build a project that I could open in Android Studio as a starting point to add in custom code like this.)

The documentation for setGlobeKeyAction
https://help.keyman.com/developer/engine/android/current-version/KMManager/setGlobeKeyAction

You should be able to add the call in MainActivity.java or SystemKeyboard.java where you’ve added your keyboard.

Something like

KMManager.addKeyboard(...);
KMManager.setGlobeKeyAction(KeyboardType.KEYBOARD_TYPE_SYSTEM, 
   GlobeKeyAction.GLOBE_KEY_ACTION_ADVANCE_TO_NEXT_SYSTEM_KEYBOARD);

Keyman 14 will add another globe option that brings up the Android input method picker (the menu you see in KMSample2)

1 Like