I have a Keychron K2 mechanical keyboard and the keys on the righthand side of the keyboard look like this:
I would like to swap them to a more standard layout, so that, from top to bottom, I would have Light Toggle
, Home
, Page Up
, Page Down
, and End
.
I used xev
to retrieve the key codes and wrote a small script that uses xmodmap
to swap them to my liking:
#!/bin/bash
xmodmap -e "keycode 110 = Next" && xmodmap -e "keycode 112 = Home" && xmodmap -e "keycode 117 = Prior"
This script is executed on start up and works exactly as expected.
The problem is this keyboard is both wired and Bluetooth. When I switch between wired mode to Bluetooth mode or vice-versa, the keys go back to their default position and I need to manually run my script above one more time. xev
shows to me that in both cases the key codes are the same. Is there a better way of tackling this so that these keys are swapped regardless of the keyboard mode I use?