remap key with control modifier

Glynn Clements glynn at gclements.plus.com
Thu Sep 7 19:16:50 PDT 2006


Manfred Georg wrote:

> The c and v key are inconveniently positioned in the dvorak layout
> so that I can't hit control-c or control-v with my left hand while
> moving the mouse.  Luckily I have an extra key (Super_L) which I
> can play with.
> 
> Two solutions I was looking at.
> 
> I would like to remap the super key straight to
> control-c and then have control-super be control-v and
> be able to modify both of those with shift.
> Unfortunately, this seems like a pipe dream since applications
> require that a control key actually be held down for correct behavior.
> xmodmap -e 'keycode 115 = 003'
> doesn't work, let alone the other stuff I talked about.
> 
> Approach two.  Turn the super key into a control key that also changes the
> keyboard layout (perhaps to qwerty).
> I got close to this, except that again, I can't have the key
> both change what a key produces (Mode_switch) and act as a control key.
> 
> Remap the extra key to Mode_switch
> and then add the appropriate characters to nearby keys.
> 
> xmodmap -e "remove mod4 = Super_L"
> xmodmap -e "keycode 115 = Mode_switch" # the super (windows) key
> xmodmap -e "add mod5 = Mode_switch"
> xmodmap -e "keycode 54 = j J c" # qwerty c key
> 
> now control-Mode_switch-j produces a control-c
> However, I would like to remove the "control" from that sequence,
> since I will never use Mode_switch without the control key also being
> pressed.
> 
> Am I missing something, or are these things really not possible?

They really aren't possible.

The keyboard mapping essentially consists of one table which maps
keycodes to modifiers, and another which maps modifier/keycode
combinations to keysyms.

There isn't any way to map modifier/keycode combinations to arbitrary
modifier/keysym combinations. The modifier/keycode -> keysym mapping
only determines the keysym; the modifiers aren't affected.

Once you decide that a specific keycode corresponds to a specific
modifier, any event generated while the corresponding modifier is
active[1] will always have that modifier bit set, and any event
generated while the modifier is inactive will always have that
modifier bit cleared.

[1] "active" meaning that the either the modifier key is held down or,
for locking modifiers, the toggle is in the "on" state.

-- 
Glynn Clements <glynn at gclements.plus.com>



More information about the xorg mailing list