[vox-tech] using xmodmap to swap modifier key locations

Henry House vox-tech@lists.lugod.org
Sat, 11 Oct 2003 13:12:21 -0700


--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Q=E5 l=F6rdag, 11 oktober 2003, skrev Shawn P. Neugebauer:
> Pete alluded to, but did not describe, the "xev" utility.  Use it to figu=
re
> out *precisely* what X thinks the keys are.  Do this before applying
> the new map (so, if you've already done so, you'll need to restart X). =
=20
> I doubt you need to do anything to your XF86Config file(s), necessarily,
> you just need to find the keycodes, keysyms, etc. for your keyboard.
>=20
> FYI, I use this trick in every linux environment I get my hands on, and
> it's always worked as is.

Thank you everyone for your replies. Things just get stranger and
stranger---see below. I should probably mention at this point that my real
goal is not to swap control and caps lock (I want to understand how to do
that since it is a common and seemingly simple example). My real goal is:

1. Make the left and right "Alt" keys send control.
2. Make the left "Control" key send alt.
3. Make the right "Control" key send AltGr.
4. Make the "CapsLock" key send compose.
5. Have no key send caps lock.
6. Maybe do somthing with the "Win logo" and "Menu logo" keys too, but this
is a low priority since my usual keyboard has neither or these keys.

So, back to swapping control and caps lock. Before I modify anything, xmodm=
ap reveals the following:


xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0xa),  Shift_R (0xb)
lock     =20
control     Control_L (0x8),  Control_R (0x9)
mod1        Meta_L (0xc),  Meta_R (0xd),  Alt_L (0xe),  Alt_R (0xf)
mod2     =20
mod3     =20
mod4     =20
mod5     =20


Note that no keys are assigned to lock! Shouldn't this mean that there is no
caps lock? But the "Caps lock" key does in fact turn on caps lock. According
to xev, "Caps Lock" sends Caps_Lock, and "Control" sends Control_L.

Now I run the following xmodmap commands:

!
! Swap Caps_Lock and Control_L
!
remove Lock =3D Caps_Lock
remove Control =3D Control_L
keysym Control_L =3D Caps_Lock
keysym Caps_Lock =3D Control_L
add Lock =3D Caps_Lock
add Control =3D Control_L


with the result that "Caps Lock" is still caps lock and does not send
control. (It still sends Caps_Lock according to xev.) What is really strange
is that "Control" now works like a shift key! Meaning, that if I hold down
"Control" and press letter keys, I get capital letters. But number keys are
unaffected. So it is really like a caps lock that does not lock (arguable
more useful than regular caps lock, but still bizarre.) According to xev,
"Control" sends Caps_Lock also.

Xmodmap reports:


xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0xa),  Shift_R (0xb)
lock        Caps_Lock (0x8)
control     Control_L (0x59),  Control_R (0x9)
mod1        Meta_L (0xc),  Meta_R (0xd),  Alt_L (0xe),  Alt_R (0xf)
mod2     =20
mod3     =20
mod4     =20
mod5     =20


I will keep experimenting.

--=20
Henry House
The unintelligible text that may follow is a digital signature.=20
See <http://hajhouse.org/pgp> for information.  My OpenPGP key:
<http://hajhouse.org/hajhouse.asc>.


--OgqxwSJOaUobr8KG
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/iGQki3lu92AVGcIRAn8lAJ9jn1B3Rv2vp0LZ7mswNqnFu8IQhwCfQEmv
RTGPO5D1pglup0NdihVqXik=
=9fYD
-----END PGP SIGNATURE-----

--OgqxwSJOaUobr8KG--