TLDR: keymapper sequence
Longer answer: A keymapper sequence to implement the answer given by Slider2k.
Keymapper is an app to remap your keys to perform another action, or sequence of actions. In this case I am remapping the double Volume Up press to kill the current app.
Disclaimer: I think keymapper is a great app, but it can be troublesome to get to work. Mostly to due to optimizations added by the manufactures into the firmware. Make sure to read the information given by the developer. Start by taking a look at Don't kill my app! to access how hard this maybe to get up and running in your device.
I my case my phone's manufacturer is not that bad, but I still got into trouble with the latest version of the app and had to stick to version 2.4.4.
You will probably want to start with a version from the Play Store of F-Droid.
In case you get the app to work here is the sequence I am using:
- Switch to the Key Mapper Basic Input Method, as otherwise the latter commands will not work.
- Open recents. This is equivalent to pressing
Alt+Tab, with the advantage that you do not need to hold the
- Then input the
DPAD_LEFT key. This moves to the previous app.
- The input the
DPAD_RIGHT key, to move back to the original app. I had to add this detour as the recents app ignored a direct delete key.
- Now input the
DEL key to kill the app.
- The final call to recents selects the previous app. I prefer not to be left in the app selection.
- To finish-up I restore the keyboard to Gboard.
I chose to add 300 milisecond delays in between actions to make sure the sequence always worked. However I did not test smaller delays so it might be possible to reduce these timings.