Tested on Ubuntu 21.10.
Source: https://unix.stackexchange.com/questions/414926/bind-capshjkl-to-arrow-keys-caps-to-esc
Create the configuration file:
touch ~/.my_keyboard
Add the following to ~/.my_keyboard
:
keycode 66 = Mode_switch
keysym h = h H Left
keysym l = l L Right
keysym k = k K Up
keysym j = j J Down
keysym u = u U Prior
keysym i = i I Home
keysym o = o O End
For more details on the above commands see the xmodmap ArchWiki.
Running xmodmap ~/.my_keyboard
enables the changes immediately.
To automatically run this command at startup, add this command to a script and make the script executable:
vim ~/Applications/xmodmap.sh
xmodmap ~/.my_keyboard
chmod +x xmodmap.sh
Go to "Startup Applications Preferences" and add the script as a startup program.