Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In Windows I was able to set Caps Lock to act as a second Enter, which can be pressed by the left little finger. I added this parameter to the registry to do that:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1c,00,3a,00,00,00,00,00

How can I do the same in Linux?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

The closest equivalent would be to run the xmodmap program each time you log in.

Put the following snippet in a file called .Xmodmap in your home directory:

keycode 66 = Return
clear Lock

You can see the key codes and current associated key names by running xev from a terminal. Press Caps Lock while the xev window is focused, and you'll see a something like

KeyPress event, serial 29, synthetic NO, window 0x7c00001,
    root 0x105, subw 0x0, time 96597741, (1548,225), root:(3151,256),
    state 0x0, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
"   XLookupString gives 1 bytes: (0d) "
"   XmbLookupString gives 1 bytes: (0d) "
    XFilterEvent returns: False

For most keys, you only need the keycode line. Modifiers are tracked separately: you need to match keysyms (what's on the right of the keycode … = … directive) with modifiers. The directive clear Lock removes the Lock modifier (which is Caps Lock or Shift Lock) from all keys.

Depending on your distribution and on your desktop environment, it may or may not be enough to add these lines to ~/.Xmodmap: many setups, but not all, automatically read this file at login time. If yours doesn't, run the command xmodmap ~/.Xmodmap at login time. How to do this depends on your choice of desktop environment.

share|improve this answer

in my .Xmodmap file I turn Caps Lock to Escape

clear Lock
keycode 0x42 = Escape

to turn it into Return like you want, this would do the trick

clear Lock
keycode 0x42 = Return

Very interestingly, It can be use for other key combination, for example I have

keycode 0x87 = Insert

and this turns the Context Menu key into the Insert key. ( interessing for me of course)

Like Gilles's answer say, you can use xev to determine the keycode of the key you want to reassign.

Don't forget that you have to launch:

xmodmap ~/.Xmodmap

in the startup script of the Window Manager of your user so as the key redirection is taken into account for each new session you log in.

share|improve this answer

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.