Ubuntu – Can’t remap Ctrl key with xmodmap

xmodmap

My laptop keyboard doesn't have a Right Ctrl key. And I use a different layout than the native layout of my keyboard, so there are some keys that do nothing. So I'm trying to remap one of those keys to use as a Right Control. I'm doing the following command: xmodmap -e 'keycode 97=Control_R'.
I also tried with Control_L. But the key do nothing.
Then I tested with Alt key:
xmodmap -e 'keycode 97=Alt_r'
and it works fine.

Why can't I remap the control key?

Best Answer

Changing the mapping of the control key is a two step process. The first part is to get the right information for the keycode and keysym. The second part is to make sure the modifier mapping is right.

It sounds like you've got the correct keycode already so try this instead. Create a file myxmodmap with the following

clear control
keycode 97 = Control_R
add control = Control_R Control_L

Now process the file with xmodmap

[~]$ xmodmap myxmodmap

If you want those xmodmap expressions to be processed each time you log in change the file name to ~/.Xmodmap