A quick guide on how to remap (app) buttons on Android TV remotes

An Android TV remote, with one of the media app buttons crossed out, and the Twitch logo replacing it.
ℹ️
The content of this blog post was originally a 3-year-old GitHub gist. I decided it would probably be better if I transferred it to this blog, since I have many things on here already. Also, hopefully, it helps a few people on here.

This guide shows how I did it with the TV that I use. Some steps may not be the same for your TV.

Requirements

Connecting to your TV with ADB

I won't go into details of how to connect to your TV using ADB, so please look up this guide here:

ADB connection to an AndroidTV
I’ve just got a Sony KDL-43W800C, and I intend to develop some apps for it, however I can not find any information on how to attach to it using adb for installing apks and getting the logs etc. Wh…

Installing KeyMapper

  1. Download the KeyMapper APK. (Preferably into the scrcpy folder, so you won't have to enter the path in the next step.)
  2. Run adb install <Path to KeyMapper-x.x.x.apk>. It should show something like "Installed" or "Success".
  3. Now you need to give the app some permissions. Use the following commands:
    1. adb shell settings put secure ENABLED_ACCESSIBILITY_SERVICES io.github.sds100.keymapper/io.github.sds100.keymapper.service.MyAccessibilityService
    2. adb shell pm grant io.github.sds100.keymapper android.permission.WRITE_SECURE_SETTINGS

KeyMapper is now installed!

Setting up KeyMapper

  1. KeyMapper will probably not appear in the default app list of your Android TV. Go into settings > apps and search for KeyMapper. From there you can open the app.
  2. Use scrcpy to see and interact with the screen on your pc. (Just run scrcpy.exe while being connected to your TV with ADB.)
  3. KeyMapper will tell you on top something like The accessability service isn't enabled!. Just press on the Fix button, the app should then fix it itself. (This is why we've set the permissions.)
  4. The second warning Your mappings will stop working randomly! will be there forever, as the app is mainly for Aandroid phones and Samsung, Huawei, Xiaomi and co. add some optimization stuff. At least that's for me, and I can't remove it.

Remapping a key

Keep in mind that you WILL need to do this via scrcpy as you can't do everything with your remote.

  1. Press the big plus at the bottom of the screen.
  2. Press Record trigger. Then you have 5 seconds to press the button on your remote that you want to remap.
  3. Once the trigger was added, you can go to Actions (which is at the top) and press Add action. Here you can select various actions. I used Launch app. There you get a list of apps that you can launch. Sadly, not every app is listed there. - and I don't know why.
  4. When everything is set, you can press Save and you're done!