Previous Next Table of Contents

3. BackSpace

The Slackware 3.0 uk.map (and others :-) has a bug with the BackSpace.

3.1 BackSpace History

On DEC VT100 terminals (the old original ones), there is no BackSpace key, just a Delete key. To get a CTRL-H you had to type CTRL-H. So the community of DEC users used the Delete Key to delete to the left.

The keyboard layout changed (from VT100), so that the Delete key is positioned and looks like the BackSpace key. IE the key that other VDU's gererate CTRL-H.

DEC users naturally setup up their stty erase and xmodmap configurations so that that key deleted to the left and were happy.

Most other manufacturers, followed ASCII and made that key the BackSpace key, returning CTRL-H. They set their stty erase and xmodmap files, and were happy.

At some time confusion arose, and every combination of available fixes was applied, to make that key do different things. Some distribution versions had different problems, either editing the kbd tables at console source, X11 source, or applying the xmodmap -e "keycode 22 = BackSpace" correction, from ONE-OF the X11 startup files, then doing the opposite in another.

3.2 /usr/lib/kbd/keytables/uk.map

Every PC key has a unique PC-Kbd ScanCode. The BackSpace key is 14. Different PC keyboards in different countries can have identical keyboards, but with different engravings on the key-tops.

uk.map is the file that tells the console driver what character (or function) to return for each scan code. Each key has several values and flags for Shift/Control/L-Alt/R-Alt.

Without disturbing the other settings, change the first Delete to BackSpace

keycode  14 = BackSpace        Delete
        control keycode  14 = Control_underscore
        alt     keycode  14 = Meta_Delete

After editing, load the table using loadkeys uk.map. This command is also in /etc/rc.d/rc.local (or other), so that it happens every time you boot.

3.3 stty erase ˆH

This tells the tty driver which key has a BackSpace effect, and line based applications like ftp get lines after you press return, edited by the driver.

The proper default should really be ˆH, but it is usually set by getty so that login (and password) can use it. Since /etc/gettydefs is an SVR4 thing, and I can't find definition file for agetty, I had to logout from the first virtual console (CTRL-F1) and switch to another (CTRL-F2) and run:

        stty < /dev/tty0
If you can't find the /etc/default or whatever file, you can set it in /etc/profile, but that is ugly.

3.4 vi

Vi looks at the stty settings, and allows DEL as BackSpace. It also gives a way of seeing what the key really generates. To see, goto Insert-Mode and type CTRL-V BackSpace, you either see ˆH or ˆ?. Press ESC then :q!

3.5 bash

Bash has a command line editor that recognises CTRL-A CRTL-H DEL (etc) and ignores the stty settings. So BackSpace always works (Delete doesn't).

3.6 X11

X11 uses different ScanCodes (it's not just for PC keyboards), and 'THAT key at the top right with a big left arrow' is key-22.

xmodmap -pk | less

Lists all of the keyboard table currently in use. That how you know that you DONT need to do the following:

xmodmap -e "keycode BackSpace = 22"

This runs xmodmap on a running X11 kernel, and remaps the key. If that helps you want the command run every time X11 starts up.

$HOME/.Xmodmap

It is customary for startx or openwin, to tell xmodmap to read this file, where you shouldn't have to put the command (only the part within the quotes, the -e option means run a single expression without reading from a file).

/var/X11R6/lib/xinit/.Xmodmap

This sets it globally for X11, but my file only (already) contains the BackSpace Fix (re-enforces the correct value), it doesn't define the keyset.

X11 globally

I don't know how to set it globally, I partly believe that the Linux Console kbd-map is used. In the olden-days man pages used to have a FILES: section.

But I still don't know which script calls it where.

Left-handed mice

Don't edit /etc/XF86Config, but put a command into your $HOME .xinitrc, eg

        xmodmap -e "pointer = 3 2 1"    # man xmodmap


Previous Next Table of Contents