Unix Power ToolsUnix Power ToolsSearch this book

6.2. Using xev to Learn Keysym Mappings

The xev client is essential for debugging X Window System keysym mappings (Section 6.1). When you start up xev, a small "event window" appears. All events that take place within that window are shown on standard output. This means screenfuls of output, but it also means that when you type a key, you can immediately trace the resulting event. For example, if you need to know what keysym is sent when you type the DELETE key on the keyboard, just run xev and type the DELETE key in the event window. Typical output might be the following:

KeyPress event, serial 13, synthetic NO, window 0x800001,
   root 0x8006d, subw 0x800002, time 1762968270, (50,36),
   root:(190,176), state 0x0, keycode 27 (keysym 0xffff, Delete),
   same_screen YES, XLookupString gives 1 characters: "^?"

KeyRelease event, serial 15, synthetic NO, window 0x800001,
   root 0x8006d, subw 0x800002, time 1762968336, (50,36),
   root:(190,176), state 0x0, keycode 27 (keysym 0xffff, Delete),
   same_screen YES, XLookupString gives 1 characters: "^?"

This tells you that the DELETE key (keycode 27) is interpreted as keysym 0xffff, which is Delete and character ^?. If you do an xmodmap -pk (Section 5.1), you should see a line resembling:[24]

[24]The keycode numbers may vary from system to system, depending on how your key mappings are configured. For example, under a Debian 2.2 install running inside VirtualPC on a Powerbook G3, DELETE is keycode 107, whereas under OroborusX on the same machine, the same keypress produces keycode 59, the BACKSPACE character. On both systems, however, the hexadecimal keysym values for DELETE and BACKSPACE are the same: 0xffff and 0xff08, respectively.

27      0xffff (Delete)

If you redefine the DELETE key as the BACKSPACE key and do the same exercise (run xev and press the DELETE key), you should see something like this:

% xmodmap -e "keysym Delete = BackSpace"
% xev
        ...
KeyPress event, serial 13, synthetic NO, window 0x800001,
   root 0x8006d, subw 0x800002, time 1763440073, (44,39),
   root:(240,235), state 0x0, keycode 27 (keysym 0xff08, BackSpace),
   same_screen YES, XLookupString gives 1 characters: "^H"

KeyRelease event, serial 15, synthetic NO, window 0x800001,
   root 0x8006d, subw 0x800002, time 1763440139, (44,39),
   root:(240,235), state 0x0, keycode 27 (keysym 0xff08, BackSpace),
   same_screen YES, XLookupString gives 1 characters: "^H"

This tells you that now the DELETE key (still keycode 27) is being interpreted as hexadecimal 0xff08, keysym BackSpace, and generates character "^H." xmodmap -pk should show you the following:

27      0xff08 (BackSpace)

For more information, see O'Reilly & Associates' X Window System User's Guide, Volume 3.

--LM, EP, and SJC



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.