Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Could anyone please tell me how to remap my Super(left) key to Ctrl key?

I mean Super(left) should work as Ctrl key..

share|improve this question
    
Do you want only the left Super key to act as Ctrl? It's easy to remap both at once from the Keyboard Layout settings, but changing only one would have to be done through config files. –  pconley May 15 '12 at 5:24
    
Yes, I want only left Super key to act as Ctrl.. –  Sandy May 15 '12 at 8:08
add comment

3 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 with

    xmodmap .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.

  1. 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.

  2. 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.

share|improve this answer
    
First of all thanks for spending time for me. When I typed "remove mod4 = Super_L" in terminal I got this message: remove mod4 = Super_L: command not found. Screenshot: i.imgur.com/fbvEA.png –  Sandy May 16 '12 at 8:45
    
That's a command for the xmodmap utility. You have to run it by one of the methods I gave in the first section. I've edited my answer to make that more clear. –  pconley May 16 '12 at 14:59
    
It worked!!! Thanks a lot. I'm very happy :D –  Sandy May 16 '12 at 19:31
    
Could you also please tell me how to run those commands at startup? –  Sandy May 17 '12 at 17:46
    
When you log in, or when the system boots? If the former, just put the commands in the file '.xmodmap' in your home directory; the latter would be more appropriate for a separate question along the lines of 'how do I execute a script on startup' (such questions have presumably been asked before). –  pconley May 18 '12 at 6:43
add comment

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
share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.