Could anyone please tell me how to remap my Super (left) key to Ctrl key?
I mean Super (left) should work as Ctrl key.
46 Answers
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 .xmodmaprcIf you name the file
~/.xmodmapit 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 -pmin a terminal window to get a list of the bound modifiers. On my machine (and presumably yours) Super is referred to asmod4.Super_LandSuper_Rare 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_LNow 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_Rto rename the key, then
add mod4 = Super_Rto assign it to Super.
5Command 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
On Ubuntu, you can edit /etc/default/keyboard and set:
XKBOPTIONS="altwin:ctrl_win"
Which:
Ctrl is mapped to Win keys (and the usual Ctrl keys)
Read man 5 keyboard for more information. You can find all possible combinations of options on your system by doing:
grep alt /usr/share/X11/xkb/rules/evdev.lst | grep win Try with this:
clear Control
clear mod4
remove Control = Control_L Control_R
remove mod4 = Super_L Super_R
add Control = Super_LPut the above lines in your ~/.Xmodmap and execute xmodmap ~/.Xmodmap.
Simple and clear example of swapping Ctrl and Alt
Create a file at ~/.Xmodmap. The file content should be this:
! -*- coding: utf-8 -*-
! 2013-02-04
! swap Ctrl and Alt keys
! here's the default setting on special keys
! xmodmap -pke | grep -P '(Control|Super|Alt|Menu)'
! keycode 37 = Control_L NoSymbol Control_L
! keycode 64 = Alt_L Meta_L Alt_L Meta_L
! keycode 105 = Control_R NoSymbol Control_R
! keycode 108 = Alt_R Meta_R Alt_R Meta_R
! keycode 133 = Super_L NoSymbol Super_L
! keycode 134 = Super_R NoSymbol Super_R
! keycode 135 = Menu NoSymbol Menu
! keycode 147 = XF86MenuKB NoSymbol XF86MenuKB
! keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
! keycode 206 = NoSymbol Super_L NoSymbol Super_L
clear control
clear mod1
keycode 37 = Alt_L Meta_L
keycode 105 = Alt_R Meta_R
keycode 64 = Control_L
keycode 108 = Control_R
add control = Control_L Control_R
add mod1 = Alt_L Meta_LNow, run this line in terminal:
xmodmap ~/.XmodmapTaken from Xah Lee: Linux, Swap Control Alt Keys