Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 3921  / 2 Years ago, sun, june 19, 2022, 4:25:48

I want to remap Control, so that:




  1. If it is pressed and released with no other key, it acts as
    Esc.

  2. If it is pressed & held together with another key, it
    acts as Ctrl (no change in behaviour in this case).



I'm aware of How do I remap certain keys or devices?, so I suspect it may be done with xmodmap. But that answer does not explain how to map the modifier keys. I looked into the examples and grammar sections of the xmodmap manpage, but they do not explain that. The answer in Remapping Caps Lock to Control and Escape (not the usual way) mention that it is not possible to do that to Caps Lock, since it is a Lock key, but I hope this may be possible to do it with Control which is a mod key. A solution with something different than xmodmap will also be accepted. (I'm running Xmonad in Ubuntu 12.04, so perhaps there is a way to set this up in xmonad.hs?)



EDIT: The closest I can get is:



xmodmap -e 'remove Control = Control_L'
xmodmap -e 'keysym Control_L = Escape'
xmodmap -e 'add Control = Escape'


With this I get Escape when I press the Left Ctrl key alone, but to get, say, Ctrl+A I have to press the Left Ctrl key twice: Ctrl, Ctrl+A (rather than just Ctrl+A) - not sure why I need to press it twice.


More From » keyboard

 Answers
3

The latest reply to Remapping Caps Lock to Control and Escape (not the usual way) says this utility will do what you want: https://github.com/alols/xcape


[#34105] Monday, June 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bathtusain

Total Points: 380
Total Questions: 124
Total Answers: 111

Location: Trinidad and Tobago
Member since Sat, Apr 9, 2022
2 Years ago
bathtusain questions
Sun, Jul 17, 22, 03:13, 2 Years ago
Sun, Oct 3, 21, 00:24, 3 Years ago
Sat, Apr 22, 23, 00:24, 1 Year ago
Fri, Jul 22, 22, 12:01, 2 Years ago
Sun, Jun 27, 21, 02:31, 3 Years ago
;