Could anyone please tell me how to remap my Super (left) key to Ctrl key?
I mean Super (left) should work as Ctrl 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 with
xmodmap .xmodmaprc
If you name the file ~/.xmodmap
it will be executed automatically on login.
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 as mod4
. Super_L
and Super_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.
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.
keysym Super_L = Control_L
Feb 10, 2018 at 9:25
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:
Keyboard & Mouse
Additional Layout Options
Ctrl position
Swap Left Win with Left Ctrl
Alt/Win key behavior
Ctrl is mapped to Win keys (and the usual Ctrl keys)
will leave you without both left and right Win key. I haven't found the way to do it through GUI without interfering with other win/ctrl keys.
May 15, 2020 at 13:12
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_L
Put the above lines in your ~/.Xmodmap
and execute xmodmap ~/.Xmodmap
.
There is an app called Input Remapper that has a GUI where you can easily rebind almost any key
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_L
Now, run this line in terminal:
xmodmap ~/.Xmodmap
Taken from Xah Lee: Linux, Swap Control Alt Keys
Windows
key on PC keyboards andCommand
key on Apple keyboards. I'm no entirly sure what the other key you describe is