How to remap Super (left) key to Control key
To make major changes to your keyboard, including remapping characters and changing modifiers, you need to use the xmodmap utility - see man xmodmap
. There are a couple ways to execute the changes:
-
either from the command line
xmodmap -e "your commands"
-
or write the commands to a file like
.xmodmaprc
, then execute it in your login items or your .bashrc withxmodmap .xmodmaprc
If you name the file
~/.xmodmap
it will be executed automatically on login.
Now the commands
What you want to do is a two-step process. First you unmap Super from its modifier, then you map it to control.
-
Run
xmodmap -pm
in a terminal window to get a list of the bound modifiers. On my machine (and presumably yours) Super is referred to asmod4
.Super_L
andSuper_R
are separate keys which output the same modifier.Now you can unmap the modifier from it. Run the xmodmap command (using one of the methods above)
remove mod4 = Super_L
Now the physical key is still referred to internally as Super_L, but it doesn't do anything.
-
Now just remap it. Run the xmodmap command:
add control = Super_L
If you want to undo this later on, just run the same commands with the appropriate arguments.
No Super_R?
The output of xmodmap -pm might given you several keys named Super_L but none named Super_R). If it did, you now have several extra keys assigned to Control, but none assigned to Super. You'll have to rename one key. (NB: it might give you several Super_L and at least one Super_R. This is fine.)
The key names in the table all have a hex number in parentheses next to them. This number is the physical keycode of the key on your keyboard (it can vary by model). If you need to change one Super_L to Super_R, first find the keycode you want to be associated to Super_R (aren't sure which is the correct one? Run xev
then tap the right Super a couple times. Somewhere in the maze of output is "keycode = 133" (with a different number)). Run the xmodmap command
keycode 133 = Super_R
to rename the key, then
add mod4 = Super_R
to assign it to Super.
Command line:
xmodmap -e "remove mod4 = Super_L"
xmodmap -e "add control = Super_L"
Or put in ~/.Xmodmap
to activate on startup:
remove mod4 = Super_L
add control = Super_L
If you want to do with with a GUI:
- Install/open Gnome Tweaks
- Click
Keyboard & Mouse
- Click
Additional Layout Options
- Expand
Ctrl position
- Select
Swap Left Win with Left Ctrl