0

On my USB-C keyboard which I use with my Android phone (Samsung Galaxy S23), the placement of the right shift-key is very weird and I keep hitting the "up" cursor key, which I curse the keyboard designers for.

There is a thread with (kind of) a solution for exactly the same problem for Windows here:
Solutions for keyboard with awkward up arrow key
but I haven't seen anything the likes for Android.

So the question is: can I flip the keys, so that the physical "up" key has the menaing of "Shift" and vice versa, in Android? If it doesn't work natively, can you recomment an app that allows this?

1 Answer 1

0

This may be old, but I haven't found evidence that this has changed in all the years of Android. Full details are from an old AOSP github repo. This will require root access as it requires you to edit system-level files.

Android uses the standard Linux input event device (/dev/event0) and driver as described in the linux/input.h kernel header file. For more information regarding standard Linux input drivers, please see Linux Input drivers at http://kernel.org.

Key Layout Map Selection of a Key Layout Map Key layout maps are installed in /system/usr/keylayout and /data/usr/keylayout.

For each keyboard device xxx, set the android.keylayout.xxx system property (see Building New Device for help setting system properties). If you don't specify a keylayout file, Android will default to /system/usr/keylayout/qwerty.kl.

File Format Key layout maps are stored on the device as UTF-8 text files and have the following characteristics:

Comments: The pound symbol (#) denotes a comment and everything after the pound symbol on a line is ignored.

Whitespace: All empty lines are ignored. Key definitions: Key definitions follow the syntax key SCANCODE KEYCODE [FLAGS...], where SCANCODE is a number, KEYCODE is defined in your specific keylayout file (android.keylayout.xxx), and potential FLAGS are defined as follows:

SHIFT: While pressed, the shift key modifier is set

ALT: While pressed, the alt key modifier is set

CAPS: While pressed, the caps lock key modifier is set

WAKE: When this key is pressed while the device is asleep, the device will wake up and the key event gets sent to the app.

WAKE_DROPPED: When this key is pressed while the device is asleep, the device will wake up and the key event does not get sent to the app.

Using the above commands to help, you could change the file from something like:

key 13    DPAD_UP
key 15    SHIFT

to:

key 13    SHIFT
key 15    DPAD_UP

This was a big nostalgia moment for me - I used to be really into keyboard remapping back in the "new-ROM-every-other-afternoon" days.

2
  • Thank you for the idea and the explanation!
    – Big J
    Commented Jan 31 at 18:16
  • 1
    That's definitely something I'll try if needed. Since it is a dual-sim phone where one of the SIM cards is from my employer though, I think I can only get root access (without getting in trouble) while that card is not in. So while I like working with down-to-earth solutions like this one, I must say in this case I'd prefer an app without root access, if that exists. But if there are no other solutions in the next days, I'll try that one out!
    – Big J
    Commented Jan 31 at 18:19

You must log in to answer this question.

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