n8blog
distraction in action

Like my work? Check out HexaLex, my game for iPhone & iPod Touch. It's a crossword game like Scrabble, but played with hexagonal tiles. http://www.hexalex.com

It's nice to see this article, which nicely explains how to clear up the mess that you sometimes
see with backspace and delete keys on Unix sytems. It's not perfect, however,
in that it doesn't really tell you how to figure out what keycodes the BS and
Delete keys send on your machine. The answer is to run the
xev utility that is normally installed on any X11 system. It pops
up a window and starts spewing loads of output to the terminal you ran it from.
The output is a log of every X event that the window receives. To figure out
what keycode Backspace (or any other key) sends in X, move your mouse to that
window and hit the key you're interested in.

When I do that with the Backspace key I get:

KeyPress event, serial 24, synthetic NO, window 0x1000001,
    root 0x57, subw 0x0, time 41167852, (177,28), root:(1136,123),
    state 0x0, keycode 59 (keysym 0xff08, BackSpace), same_screen YES,
    XLookupString gives 1 bytes:  "

KeyRelease event, serial 24, synthetic NO, window 0x1000001,
    root 0x57, subw 0x0, time 41167935, (177,28), root:(1136,123),
    state 0x0, keycode 59 (keysym 0xff08, BackSpace), same_screen YES,
    XLookupString gives 1 bytes:  "

By reading this output we see that the first event is the key press and the second is the release. Both send the keycode 59 (not keycode 22 as on James'
system), which is correctly mapped to the keysym BackSpace.

Thankfully, this BS vs. Delete issue is one that rarely comes up these days.
All of the Unix systems I've used in the last 5 years or so have been configured
correctly on delivery.

  • Share/Bookmark

  Comments:

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Please type this word with the letters reversed: live

Like my work? Check out HexaLex, my game for iPhone & iPod Touch. It's a crossword game like Scrabble, but played with hexagonal tiles. http://www.hexalex.com