Ubuntu – Swapping right shift and delete key using xmodmap

keyboardxmodmap

I'm unsure how to swap these 2, this is the thought process I had but am unsure how to get it working:

remove sh = Shift_R
remove dl = Delete

keysym Delete = Shift_R
keysym Shift_R = Delete

add sh = Delete
add dl = Shift_R

This is based on the code I use to swap caps lock and control.

Any thoughts?

xmodmap output:

dan@lantea:~$ xmodmap -pke | grep Shift_R
keycode  91 = Shift_R NoSymbol Shift_R
keycode 119 = Shift_R NoSymbol Shift_R
dan@lantea:~$ xmodmap -pke | grep Delete
keycode  62 = Delete NoSymbol Delete

Best Answer

You can use the following commands:

xmodmap -e "keycode 62 = Delete NoSymbol Delete"    #this will make Shift_R key to act as delete
xmodmap -e "keycode 119 = Shift_R NoSymbol Shift_R" #this will make Delete key to act as right shift

To get this change for every session, after you have run the ​​previous commands, create a file called .xmodmap with the new keymaps, using the following command:

xmodmap -pke > .xmodmap

Then, create a file called .xinitrc in your home directory, containing the following line/command:

xmodmap .xmodmap

And finally, make .xinitrc file to be executable:

chmod 755 ~/.xinitrc
Related Question