Linuxdoc Linux Questions
Click here to ask our community of linux experts!
Custom Search

8. More Hacking

So, you're not happy with the information you got. In this case, there is even more hacking you can do on the Backspace/Delete issue, using suitable commands that get or set the way X and the console handle keys.

It could happen that, for some reason, what I said talking about X is not true, that is, X does not translate keycode 22 to keysym BackSpace and keycode 107 to keysym Delete (or even that, on your particular keyboard, the keycodes associated to Backspace/Delete are not 22 and 107). To be sure of that, you need to use xev, a simple X application that will display the keycode and keysym associated to the key you press. If anything goes wrong, there are several ways you can fix the problem: the easy, temporary way is to use xmodmap, a command that lets you change many settings related to X keyboard handling. For instance,

xmodmap -e "keycode 22 = BackSpace"
xmodmap -e "keycode 107 = Delete"
will set correctly the keysyms (assuming that 22 and 107 are the correct keycodes for you). In case you want to do some changes permanently, you can play with the resources vt100.backArrowKey, vt100.translations and ttyModes of xterm (and similar terminal applications) in the configuration file ~/.Xdefaults. One possibility, for instance, is
XTerm.VT100.Translations: \
        <Key>BackSpace: string(0x7F)\n\
        <Key>Delete:    string("\033[3~")
You should take a look at the xterm man page for more information.

The program that does for the console what xev does for X is showkeys: it will dump the console keycodes of the keys you press. Combining showkeys with dumpkeys, which will print on standard output the console keymap, you can easily fix mismatches between keycodes and keysyms. Analogously to xmodmap, loadkeys can then fix single associations, or load entirely new console keymaps. With it, you can even change the string associated to a given keysym. If you want to record these changes, you will have to define a new keymap for the console (you should have a look at the system keymaps, usually located in /lib/kbd).