I have found many discussions about how to use a different layout or swap two key, say, caps lock and CTRL, by something like External Keyboard Helper Pro, but is it possible to remap key shortcut, say, map ctrl+hjkl to arrow key in Android like powertoys in Windows and xkeysnail in Linux?

1 Answer 1


Keyboard customization in Android could be done via modifying Key layout files (*.kl) or Key character map files (*.kcm). KL files specify which Android key is produced by each physical key. KCM files specify how to interpret Android keys and combinations of Android keys with modifier keys.

In your case you need a custom KCM file. You should start from a KCM file of your language. There are default KCM files for different languages from AOSP sources.

Suppose you use en-US keyboard layout. There is keyboard_layout_english_us.kcm. You should add your modifications with ctrl to H,J,K,L Android keys. Something like this:

key H {
    label:                              'H'
    base:                               'h'
    shift, capslock:                    'H'
    ctrl:                               fallback DPAD_LEFT
key J {
    label:                              'J'
    base:                               'j'
    shift, capslock:                    'J'
    ctrl:                               fallback DPAD_DOWN
key K {
    label:                              'K'
    base:                               'k'
    shift, capslock:                    'K'
    ctrl:                               fallback DPAD_UP
key L {
    label:                              'L'
    base:                               'l'
    shift, capslock:                    'L'
    ctrl:                               fallback DPAD_RIGHT

I don't have external keyboard right now so I can't check it.

Note: you can find other Android keys in Generic.kl file (last column).

Next, you need to apply your custom KCM file. There are two ways:

  1. Upload it to your device with root access as described in documentation in "Location" section.
  2. Install an app with your custom KCM file built in. No root required. Then you need to select that layout in keyboard's layout settings.

There is tutorial of how to build such app.

If you don't want to or don't know how to build such app, there is ExKeyMo web app (disclaimer: I'm the developer). Just enter your KCM file in the form and click Download. It will build the app for you.

Update: to verify your KCM file you should use validatekeymaps tool. There is web version of this tool (disclaimer: I'm the developer).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .