Monday, November 17, 2014

Remap capslock in android

I bought a hardware keyboard to go with my tablet.

As usual the first very annoying thing I always deal with is remapping capslock to ctrl.

It's fairly simple in android providing you have root or the ability to modify /system.

I was not able to do adb remount on my device (despite having root) this intermediate workaround however solved the problem. http://androidforums.com/nexus-4-all-things-root/802434-adb-remount-fails-work-around-successful.html

The result is:

On device
$ su
# mount -o remount,rw /system
On Host
$ adb pull /system/usr/keylayout/Generic.kl .

Make the correct modifications to the Generic.kl file. (should be obvious, just replace CAPSLOCK with CTRL_LEFT)
I wasn't able to push directly to /system/usr/keylayout due to root issues with adb.
The solution was to push to /sdcard then move.
On Host
$ adb push Generic.kl /sdcard/Generic.kl

On device:
$ su
# cp /sdcard/Generic.kl /system/usr/keylayout/Generic.kl
# chmod 644 /system/usr/keylayout/Generic.kl

Reconnect the usb keyboard and CAPS_LOCK should now be remapped!

No comments:

Post a Comment