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.

I'm trying to remap a bunch of my keys and I'm running into trouble. I'm currently trying to use xmodmap but failing. Maybe there is a better way?

Can someone explain how I can best remap Ctrl-j on the keyboard to produce Ctrl-c?

It's not as easy as just making j=c. I want this happen only when I'm holding down ctrl.

share|improve this question

2 Answers 2

There is a tool called hotkeys that can be found in the Ubuntu repositories that does this.

share|improve this answer
    
Try using the tool 'hotkeys' (to find in ubuntu repositories). –  Ice Mar 28 '10 at 20:40

The short answer: you can't.

What happens when you press Ctrl+j is that you get a sequence of events:

  1. "Ctrl key pressed"
  2. "J key pressed (Ctrl held)"
  3. "J key released (Ctrl held)"
  4. "Ctrl key released".

With tools like xmodmap, you can change which physical key corresponds to "Ctrl" and "J" (strictly: which keysyms are mapped to which key), but you can't influence just the combination.

What you could do is try to intercept the keystrokes and atrificially emit others; in this case:

  1. "Ctrl down" - pass through
  2. "J down (Ctrl held)" - replace with "K down (Ctrl held)"
  3. "J up (Ctrl held)" - replace with "K up (Ctrl held)"
  4. "Ctrl up" - pass through.

I understand there's at least one set of tools (xbindkeys and xmacro) that should allow you to do this, but I haven't tried them myself, and learning how to do this may leave you without the ability to enter a "J", so do it with care (and make sure you can reboot into a default state until you're happy with the result). I found the tool description here.

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.