Ubuntu – Customize keyboard layout including navigation keys

keyboardkeyboard-layoutnavigation

I know how to customize the keyboard layout as explained here. it works with symbols and numbers, but how can I assign navigation keys?

What I want to do is to assign the arrows and other navigation keys to use them with alt gr:

  • alt gr + s = left
  • alt gr + d = down
  • alt gr + f = right
  • alt gr + e = up
  • alt gr + t = prev page
  • alt gr + v = next page
  • alt gr + a = home
  • alt gr + g = end
  • alt gr + z = delete
  • alt gr + q = escape
  • alt gr + r = insert

Thank you

Best Answer

I found the solution here

and these changes did what I wanted. Now I can use the directions and numbers without moving my hands position.

First, run xev and press the keys to find their keycodes.

Create a script with the following:

#!/bin/bash

xmodmap -e "keycode 24 = q Q q Q Escape Escape"
xmodmap -e "keycode 25 = w W w W Delete Delete"
xmodmap -e "keycode 26 = e E e E Up Up"
xmodmap -e "keycode 27 = r R r R Prior Prior"
xmodmap -e "keycode 28 = t T t T Prior Prior"
xmodmap -e "keycode 29 = y Y"
xmodmap -e "keycode 30 = u U u U 7"
xmodmap -e "keycode 31 = i I i I 8"
xmodmap -e "keycode 32 = o O o O 9"
xmodmap -e "keycode 33 = p P"

xmodmap -e "keycode 38 = a A a A Home Home"
xmodmap -e "keycode 39 = s S s S Left Left"
xmodmap -e "keycode 40 = d D d D Down Down"
xmodmap -e "keycode 41 = f F f F Right Right"
xmodmap -e "keycode 42 = g G g G End End"
xmodmap -e "keycode 43 = h H"
xmodmap -e "keycode 44 = j J j J 4"
xmodmap -e "keycode 45 = k K k K 5"
xmodmap -e "keycode 46 = l L l L 6"
xmodmap -e "keycode 47 = semicolon colon"

xmodmap -e "keycode 52 = z Z z Z BackSpace BackSpace"
xmodmap -e "keycode 53 = x X x X Insert Insert"
xmodmap -e "keycode 54 = c C"
xmodmap -e "keycode 55 = v V v V Next Next"
xmodmap -e "keycode 56 = b B b B Next Next"
xmodmap -e "keycode 57 = n N n N 0"
xmodmap -e "keycode 58 = m M m M 1"
xmodmap -e "keycode 59 = comma less comma less 2"
xmodmap -e "keycode 60 = period greater period greater 3"
xmodmap -e "keycode 61 = slash question"

Give the script execution permissions with

sudo chmod 755 xmodmap.sh

To make this permanent, add this command to the startup applications:

/bin/bash -c "sleep 7 && /home/myusername/xmodmap.sh"