Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Can I change the Caps Lock key to Control and still keep the on/off nature of Caps Lock? I've checked into using xmodmap and seem to have hit a dead end. Many people want to swap them, but they also want to swap the way they work. I'd rather keep my new Control key as an on/off switch for Control.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

There's no low-level support for a Ctrl Lock in either Linux or Xorg outside of bugs, so you'll either need software that will feed the Ctrl press back into some input buffer in order to simulate a lock, or you'll need a keyboard that supports it directly.

share|improve this answer
    
Thanks, at least now I know not to keep trying to do it by messing with keymappings. –  MalcolmWhy Oct 18 '10 at 19:57

As Ignacio said, it cannot be done with keymaps. But it can be e.g. simply scripted using xbindkeys and xdotool.

First, strip Caps Lock of its special functionality using xmodmap (this has to be done each time X is started):

xmodmap -e 'keycode 66 = F13'

Then, add the following bindings to you .xbindkeysrc:

"xdotool keyup Control_L; xdotool keydown Control_L"
    F13
"xdotool keydown Control_L; xdotool keyup Control_L"
    Control + F13

This creates a fake keypress (without release) of the Ctrl key whenever Caps Lock (now F13) is pressed. The up+down sequence is there for some technical reasons of how the fake events work.

In this version, pressing (left) Ctrl releases the lock. This could be modified (either so that both controls release it, or neither does) but it would be a little more complicated (e.g. one could create another control key (e.g. F14) and fake-press that instead of Control_L).

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.