From: <ÓÉ Microsoft Internet Explorer 5 ±£´æ> Subject: BackSpace and Delete Configuration for Linux (VT, xterm, bash, tcsh, netscape and more) Date: Wed, 1 Mar 2006 21:41:53 +0800 MIME-Version: 1.0 Content-Type: multipart/related; type="text/html"; boundary="----=_NextPart_000_0000_01C63D78.F49A98A0" X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830 This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C63D78.F49A98A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Location: http://www.ibb.net/~anne/keyboard.html BackSpace and Delete Configuration for Linux (VT, = xterm, bash, tcsh, netscape and more)

Consistent BackSpace and Delete Configuration

The Linux Hall of Shame

http://www.ibb.net/~anne/= keyboard.html
version=20 0.6


Please update your bookmarks to http://www.ibb.net= /~anne/keyboard.html,=20 instead of ibbnet.nl or ibbnet.org
(it seems a porn-site has = claimed our=20 old ibbnet.org domain...).=20

Main Page|The = Alternative=20 Way |Troublesh= ooting

= = =

Index

Introducti= on
Terminology=
The=20 Problem
Solution(wor= k-arounds)
Overvie= w
Configuration of = environments...
terminf= o
Xterm<= /DIV>
X
Bash
Tcsh
... and applications
Athena-ap= ps Emacs<= /TD> JoeKDELess Nedit<= /TD> Netscap= e Pico=20 and Pine VimMutt Telnet=
These pages were = originally written=20 to address a nagging problem which bothered many people using Linux. It has to do with the default = behaviour=20 of the BackSpace and Delete keys, which did not behave as expected. The = goal of=20 this document was and still is to make [<---] (i.e. the backspace-key = on your=20 keyboard) to erase to the left, and make [Delete](i.e. the delete-key) = erase=20 under the cursor. It seems all Linux distributions I am aware of have=20 effectively dealt with the issue by now. However still lots of people = visit=20 these pages, presumably because the information presented here is = applicable to=20 other UNIX flavors and cross-platform environments and applications.=20

The keymapping problem can be traced back to the time when computers = used=20 punched tapes. The only way to correct a wrongly punched character was = to punch=20 additional bits in the tape (or rather, punch additional bits _out_ of = the=20 tape). Characters with all the bits punched were treated as deleted = characters.=20 See 'man ascii' for a list of the ASCII characterset, you'll see that = DEL,=20 (octal 177, decimal 127 and hexadecimal 7F) is the one with all the bits = punched=20 in (the ASCII code with the highest value). To be able to overwrite a = character=20 it is necessary to undo the feed between the characters first. For this = the=20 ASCII BS (octal 010, decimal 8, hexadecimal 08) was used. So to erase = the=20 last-typed character, you would have to press first BS to move back one=20 character, and then DEL to delete the character. In newer computers = either BS or=20 DEL was chosen to move back and delete in one press.

The question to use BS or DEL was (and is...) just a matter of = choice, just=20 as different operating systems chose different ways to represent = newlines, which=20 was done by first issuing a carriage return (CR) and then a line-feed = (LF). UNIX=20 chose ASCII LF (hexadecimal 0A) to do both at the same time, Macintosh = chose CR=20 and MS-DOS both. Unfortunately, in the BS-DEL case, Linux ended up with = two=20 possibilities.

The essential point in this issue is to go for one way consistently. = This=20 page describes a way to consistently use DEL to erase the previous = character,=20 the page called The = Alternative=20 Way describes a way to consistently use BS. On the latter page there = are=20 some tips which may be useful regardless of what approach you take.

At this point the best way to fix the keys on your machine is to = install Debian from version 2 (Hamm) and up, = or SuSE.

If you miss an application on this page, it's either because the keys = are ok=20 in the application ("If it ain't broken, don't fix it"), or because I = don't know=20 about it. In either case, don't hesitate to mail me about it.

Throughout this document, = [<---]=20 and [Delete] are used to denote the physical keys on the keyboard, the = things=20 you actually press to erase characters. There are a few things to keep = in mind:=20 ASCII values can be represented in several equivalent ways. This means = that=20 ASCII BS is equivalent to 010 in octal, 8 in decimal and 08 in = hexadecimal=20 notation. To show that a number is in hexadecimal notation '0x' is put = in front=20 of it. Finally it should be noted that BS and DEL are known to = applications by=20 their corresponding control sequences. To sum it up:=20
Note:
ASCII BS =3D=3D 0x08 =3D=3D ^H
ASCII DEL =3D=3D 0x7f =3D=3D 0177 =3D=3D=20 ^?

The reason the keys = (generally) do=20 not work out-of-the-box is partly lack of configuration (as you will see = later,=20 simply creating .inputrc/.cshrc already helps a lot) and a = more=20 difficult issue which I will try to describe below.=20

The linux console emulates a vt220 terminal which has the following=20 key-mapping:

Linux console/VT220
Key            KeySymName       Console characters
  --------------------------------------------------
  Ctrl+H   --->  Control_H  --->  ASCII  BS (0x08)
  [<---]   --->  Backspace  --->  ASCII DEL (0x7f)
  [Delete] --->  Delete     --->  "\e[3~"
Note 1: BS (0x08) is equivalent to ^H, which is left to be used by = applications (e.g. for help menus in emacs, but it could be anything). = DEL is=20 equivalent to ^?, or 0177 (octal) and 0x7f (hex) and "\e[3~" will show = up in=20 your xterm (using the ^v-trick) as=20 ^[[3~. Xterms on the other hand, emulate the vt100 terminal, which = didn't have a=20 [Delete]. It did have a [<---] which generated ASCII BS (but it was = in an=20 awkward position and did not serve as rubout).
VT100
--
Key            KeySymName       Console characters
  --------------------------------------------------
  Ctrl+H   --->  Control_H  --->  ASCII  BS (0x08)
  [<---]   --->  Backspace  --->  ASCII DEL (0x7F)
Now here's how xterm emulates the VT100 terminal:
Xterm's emulation of VT100
Key            KeySymName       Console characters
  --------------------------------------------------
  Ctrl+H   --->  Control_H  --->  ASCII  BS (0x08)
  [<---]   --->  Backspace  --->  ASCII BS (0x08)
  [Delete] --->  Delete     --->  ASCII DEL (0x7F)
It may be clear that by default the keys are mapped differently on = the=20 console and in xterm. This would be ok if it weren't for the fact that = while on=20 the console ^H is free to be used by applications, in an xterm it is not = (instead it's mapped to the [<---] key). Differences between terminal = types=20 are generally dealt with by the terminfo database (see below), mapping = terminal=20 specific strings to the correct key. However, in this case, the ^H = should=20 not be mapped. Terminfo is not enough, the settings of = the=20 terminal (xterm) have to be modified such that ^H is not used.=20

In my = previous=20 attempt at working around the problem, I put most of my effort in = trying to=20 map all keys to suit xterm's vt100 emulation. However, I now propose = another way=20 to deal with the problem. This basically means getting xterm to work = with the=20 consoles' default settings: [<---] will do ASCII DEL (0x7F, or ^?), = and=20 [Delete] will do "\e[3~". This way ^H is not used for any terminal = specific=20 functions, it can be used by applications.

There is no = clear=20 solution, but there are some pretty good work-arounds. What is needed is = to tell=20 xterm = how to=20 handle the keys, and then to tell other applications about it (i.e. how = xterm=20 handles the keys). The terminfo database contains descriptions of how = all kinds=20 of terminals handle (terminal specific) keys. Applications look at the = TERM=20 variable, and then search the corresponding database for the value of a = certain=20 key, e.g. the left-arrow key, and find the string that corresponds to = it. This=20 means that the strings in the database had better correspond to your = current=20 xterm settings. This involves modifying xterm's terminfo entry.=20

When you change the keymapping on your own system, you may have = problems when=20 accessing other systems. Luckily, this can be worked-around by a script = which=20 changes the input it receives to the output that is expected by the = application=20 (telnet, rlogin). See the telnet= =20 section.

This table summarizes the=20 modifications needed in the different environments, and the tools it is = done=20 with:=20
= =
Environment    
      Configuration=20 = files           
Configuration 
user   
 systemwide       &nbs= p;
Terminf= o          -         terminfo      &= nbsp;          infocmp/tic  &nbs= p;
Xterm&= nbsp; ~/.Xdefaults (*)  /etc/X11/Xresources  xrdb ~/.Xdefaults (*)
X &nb= sp;             -   /etc/X11/xinit/.Xmodmap (**)   xmodmap .Xmodmap  
Bash&nb= sp;     ~/.inputrc    /etc/inputrc    export INPUTRC=3D/etc/inputrc  
Tcsh&nb= sp;     ~/.cshrc      /etc/cshrc           bindkey=20 (shellcommand)  
* = or=20 .Xresources
** /etc/X11/XF86Config also = affects the=20 keyboard settings under X=20
This is often a problem. = When you=20 find that the keys are fine in e.g. vi on the console, but not in an = xterm (or=20 vice versa, or both) it means that your xterm-settings do not correspond = to the=20 settings listed in the terminfo database. I am not really comfortable = with=20 telling you to fiddle with terminfo, please be careful, make backups! If = you run=20 the tic command on the modified de-compiled terminfo entry as root, your = system's terminfo database will be modified automagically. Put the = original file=20 in a save place so you can run tic on it and restore the original state. = Read=20 the manpage. First try it as non-privileged user. You can start with = testing a=20 modified xterminfo file (see below) as explained, however, since these = are=20 likely to differ from your system's entry at other points, it's probably = better=20 to modify your own instead. At any rate, first find out whether the = terminfo=20 entry for xterm is in accordance with your xterm settings: =
infocmp | grep kbs
should return a line which includes kbs=3D\177. This = means DEL=20 (or ^?) is mapped to the backspace key, which is what we want. =
infocmp | grep kdch1
should return a line with kdch1=3D\E[3~. This means = that \E[3~=20 is mapped to the delete key. Often you will find kbs=3D^H and/or = kdch1=3D\177, or=20 there will be no kdch1 at all. You can either edit the terminfo entry as = described on the T= roubleshooting-page=20 (simply setting or adding kdch1=3D\E[3~ and = kbs=3D\177,=20 but make a backup first!) or you could download (click shift or right) a = modified debian=20 xterminfo or redhat=20 xterminfo and test it. Put the file in = ~/.terminfo/x/xterm (for=20 testing purposes) and do for bash:
export =
TERMINFO=3D~/.terminfo
and/or for tcsh:
setenv TERMINFO ~/.terminfo
Make sure that the TERM variable is set to xterm:
echo =
$TERM
should return "xterm". If it works as intended (do 'toe' to check = whether=20 the terminfo dir you specified is indeed used, toe will return a list of = available terminfo types, only xterm in this case), you can run tic as = root,=20 which will copy the file to
/etc/terminfo/x/xterm
(debian) or =
/usr/lib/terminfo/x/xterm
(redhat, slackware). Make backups first, and = test it=20 before you replace any files!=20
The xterm (and friends) only = needs little=20 configuration. In the /etc/X11/Xresources or=20 ~/.Xdefaults (or wherever it's merged with the other = xresources)=20 add the line:
*VT100.Translations: #override \
              <Key>BackSpace: string(0x7F)\n\
              <Key>Delete:    string("\033[3~")\n\
              <Key>Home:      string("\033[1~")\n\
              <Key>End:       string("\033[4~")
*ttyModes: erase ^?=20

Rxvt only uses Xresources if it is compiled with this = option.=20 Since rxvt uses readline, to get home and end to work you will have to = edit=20 .inputrc, see the Bash = section).=20 Redhat users can pick up the SRPM = (source)=20 and compile rxvt themselves with this feature.h, = ensuring the=20 right keybindings.

Putting xterm or nxterm in front of=20 *vt100.translations makes the settings specific for xterm = or=20 nxterm. Sometimes this does not seem to work properly, in that case try = using=20 both nxterm*VT100.Translations and=20 xterm*VT100.Translations.

BTW, have I told you that Ctrl-v = <key> will=20 tell you what sequence is sent to the shell? Try Ctrl-v = [Delete],=20 it should give a ^[[3~ in your xterm or console (try it = with [ESC]=20 and you'll find ^[, which corresponds to \e for readline apps, and \033 = for=20 Xresources).

1. The syntax of the Xresources files is very strict, = make sure=20 you don't leave blank spaces after the backslash on each line. Also = watch the=20 newline (\n\) sequences, there shouldn't be one at the last = line of=20 an entry.
2. The sections are named, if you only use=20 *VT100.Translations it will work for all xterm and = friends.
3.=20 For info about Xresources and other X related stuff refer = to 'man = X'.


X

If you use XFree86, make sure you have enable = the XKB=20 extensions in /etc/X11/XF86Config. It is enable by default, = so it=20 should be okay. Note the different keyboard layout-options. Now XFree86 = will=20 translate the console mapping, and everything should work in X. If you = have=20 problems, or want to fiddle with additional characters and things, = create an=20 Xmodmap. Also if you want the keyboard to generate special=20 characters in X, xmodmap can also be used to configure the=20 function-keys. This is adequately described in the manual page = ('man=20 xmodmap'. Make sure that the following lines are included in your = Xmodmap:=20

keycode 22 =3D BackSpace
keycode 107 =3D = Delete

Note that the keycodes in X are not the same as in a = VT. Use=20 showkey to see the keycodes generated by the keyboard in a = VT, and=20 xev in X. There is an excellent graphical front end for = X-keyboard=20 configuration: xkeycaps. Refer to the Netscap= e=20 section.

Another way of generating special characters in X (without using=20 xmodmap) is by defining a Compose-key (for use as a "dead = key") in=20 XF86Config in the Keyboard section:

  =
RightCtl        Compose

Now you have a compose-key with the same properties as the one = described=20 in the VT=20 section. Remember to set the environment variable=20 LC_CTYPE=3Diso-8859-1 (see VT=20 optional...). Consult 'man= =20 XF86Config' if you want to know more. Note: = this=20 doesn't seem work rxvt.
Alternatively, owners of a windows keyboard = (one with=20 extra buttons, it need not be a M$ natural keyboard) can enable the=20 XKEYBOARD extension (enabled per default) in=20 XF86Config and uncomment the line (follow the instructions = in the=20 file):
  XkbModel    "microsoft"=20

Now you can use the button with the windows flag on it to produce = a great=20 number of exotic characters, just press it in combination with e.g. a, = producing=20 =E1 (a clear disadvantage is that there is no logic in the location of = the special=20 characters at all...).=20

Yet another way to use "dead keys" in X is by installing a modified = version=20 of libX11 which includes support for dead keys (transparent for all = apps).=20 First, get the modified version of libX11 (make sure you get the right = version,=20 if you use glibc replace both libX11, ELF-libc5 and ELF-libc6). Now, = deactivate=20 the XKB extension of XFree86 (edit XF86Config and run = xmodmap on a=20 Xmodmap file with dead keys like dead_acute, dead_grave, dead_cedilla,=20 dead_ogonek and a Multi_keys one too.

A special case is if you use xdm, you need to deactivate XKB from the = /etc/X11/xdm/Xservers file, passing a -kb parameter to the = server=20 like this:

:0 local /usr/X11R6/bin/X -kb

then in /etc/X11/xdm/Xsetup_0 file add a line to load = the=20 Xmodmap, like this:
if [ -r /etc/X11/xinit/.Xmodmap ]; then
        /usr/X11R6/bin/xmodmap /etc/X11/xinit/.Xmodmap
fi

Now chars accesible by AltGr, dead keys or compose are usable in = xdm too.=20

More Composing Talk

A problem common to all compose schemes is = that=20 while some composing systems make more sense than others, none of them = make all=20 of the iso_8859_1 characters readily accessible, simply because it is = impossible=20 to remember the combinations for all characters. So instead of, or in = addition=20 to getting special libraries, it is often desirable to simply have a = list of=20 characters you can copy from, a poor man's iso_8859_1 table so to speak. = Just=20 grab you favorite editor, open a file called iso_8859_1 (or any other = name, but=20 check the name and path) and put in all iso_8859_1 characters. Wait, = here they=20 are (you may want to create a different order):
=A1 =A2 =A3 =
=A4 =A5 =A6 =A7 =A8 =A9 =AA =AB =AC ­ =AE =AF =B0 =B1 =B2 =B3 =B4 =
=B5 =B6 =B7 =B8 =B9 =BA =BB =BC =BD =BE =BF =C0 =C1 =C2 =C3 =C4 =C5 =C6 =
=C7
=C8 =C9 =CA =CB =CC =CD =CE =CF =D0 =D1 =D2 =D3 =D4 =D5 =D6 =D7 =D8 =D9 =
=DA =DB =DC =DD =DE =DF =E0 =E1 =E2 =E3 =E4 =E5 =E6 =E7 =E8 =E9 =EA =EB =
=EC =ED =EE
=EF =F0 =F1 =F2 =F3 =F4 =F5 =F6 =F7 =F8 =F9 =FA =FB =FC =FD =FE =FF=20

Now you need a way to display them (millions of options here, I = bet you=20 can do all kinds of crazy things with fonts, colors, pixmaps, = borders...). The=20 script assumes the file with the characters is in = /usr/local/lib.
=20

#!/bin/bash=20
export LESSCHARSET=3Dlatin1=20
exec xterm -T Iso_8859_1-TABLE -geometry 77x4 +sb -bg SteelBlue -fg =
white \
-fn lucidasanstypewriter-bold-12 -e less /usr/local/lib/iso_8859_1


Refer to the manual page of iso_8859_1. If you do 'man iso_8859_1' = but you=20 don't see any special characters, edit /etc/man.config, and = change=20 the following line:
NROFF         /usr/bin/groff -Tascii =
-mandoc

to:
NROFF         /usr/bin/groff -Tlatin1 -mandoc

Now try 'man -c iso_8859_1' (the -c option is to make sure man = does not=20 use an old cat file).=20

Create a file, /etc/inputrc for system wide use or=20 ~/.inputrc for personal use. Actually, this is the readline = initialization file, readline is a library that some programs (bash, = kvt) use to=20 read input (try bind -v to see a list of readline key and = function=20 bindings). Cut and paste the following in the file to make the Delete = key delete=20 characters under the cursor, and make Home and End work as = well:

"\e[3~": delete-char
# this is actually equivalent to "\C-?": delete-char
# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# kvt
"\e[H":beginning-of-line
"\e[F":end-of-line
# rxvt and konsole (i.e. the KDE-app...)
"\e[7~":beginning-of-line
"\e[8~":end-of-line

If a system-wide /etc/inputrc was created, add the = following=20 line to /etc/profile:
export =
INPUTRC=3D/etc/inputrc

Make sure that the stty erase character is set to ^?. = Type

stty -a | grep erase

and check if it says

erase =3D ^?;

If it is set to something else (e.g. ^H) then put the = following=20 line in both .bashrc and in either = .bash_profile or=20 /etc/profile:

  if tty --quiet ; then
    stty erase '^?'
  fi

and for xterm and rxvt add this to .Xdefaults: =
*ttyModes: erase ^?
           =20

If you create /etc/inputrc, note that Bash will ignore=20 ~/.inputrc (currently this happens in all distributions = except=20 Debian, however, this might change in the future). As an alternative, = you can=20 edit ~/.inputrc, and copy this to /etc/skel/, = so it's=20 in the home directories of all new users.
Push the key-combination=20 'Ctrl-x-r' (push the control-key, the x-key. release it, = push the=20 r-key, release it, and then release the control-key) to see if the = changes in=20 inputrc take effect. Or just login again, and it will work. =

You can also change the keybindings on the fly with the = bind=20 command, e.g:

[localhost]> bind "\C-?": backward-delete-char
This is useful to test different keybindings, if they work you can = put=20 them in ~/.inputrc. Read all about it in the readline = manpage.=20

People using keymaps with e.g. Scandinavian characters who would like = bash to=20 display these characters (=F8l;-) have to add the following lines in=20 .inputrc:
set convert-meta off
set = output-meta on
set input-meta on

For more = info,=20 check the Danish-H= OWTO.


If you use the tcsh shell, put the = following=20 lines in your /etc/cshrc or your personal ~/.cshrc=20 file:
#.cshrc
 if ($term =3D=3D "xterm" || $term =3D=3D "vt100" \
            || $term =3D=3D "vt102" || $term !~ "con*") then
          # bind keypad keys for console, vt100, vt102, xterm
          bindkey "\e[1~" beginning-of-line  # Home
          bindkey "\e[7~" beginning-of-line  # Home rxvt
          bindkey "\e[2~" overwrite-mode     # Ins
          bindkey "\e[3~" delete-char        # Delete
          bindkey "\e[4~" end-of-line        # End
          bindkey "\e[8~" end-of-line        # End rxvt
      endif
 
To see whether it works or not, type:=20

[localhost]> source .cshrc



For programs = using the=20 Athena widgets (xpaint, xbmbrowser, xman, xmh, xedit, pixmap, bitmap,=20 editres...) put the following in .Xdefaults to get Delete = to work:
*Text.translations:    #override \=20
    ~Shift ~Meta <Key>Delete: delete-next-character()

In emacs, [<---] and [Delete] = are by=20 default configured to both erase the character on the left of the = cursor. To=20 change this, you can either edit the file x-win.el in the = emacs=20 root directory, and find the following:

;; Map certain keypad keys into ASCII characters
;; that people usually expect.
(define-key function-key-map [backspace] [127])
(define-key function-key-map [delete] [127])


and change the last line to
(define-key =
function-key-map [delete] [deletechar])


Alternatively you can add
(define-key function-key-map =
[delete] [deletechar])


to your ~/.emacs file. On a related note, by default in emacs the = HOME key=20 brings you to the beginning of the buffer (i.e. top of the document). = Likewise=20 the END key brings you to the end of the buffer. Adding the lines =

(define-key global-map [home] `beginning-of-line)
(define-key global-map [end] `end-of-line)

to your ~/.emacs make these keys move you to the = beginning=20 and end of the current line. Note that the M-< and M-> keybindings = remain=20 untouched and can still be used to go to the beginning and end of the = buffer.=20 First find the file joerc. It is = most likely=20 /usr/lib/joe/joerc, but sometimes /etc/joerc, = or maybe=20 even /usr/local/lib/joerc. Try 'locate joerc' = if you=20 can't find the file. Make a backup for safety, or copy it to .joerc in = your home=20 directory, and change/add the following lines in the section "Standard = JOE user=20 interface" in joerc:
bol              ^[ [ H          # =
Standard xterm escape seq.
bol              ^[ [ 1 ~        # Standard VT escape seq.
bol              ^[ [ 7 ~        # rxvt
eol              ^[ [ F          # Standard xterm escape seq.
eol              ^[ [ 4 ~        # Standard VT escape seq.
eol              ^[ [ 8 ~        # rxvt

Note that you first have to make sure that Home = and End=20 work in an xterm.= Check=20 out 'man=20 joe'. BTW, these modifications apply to jpicorc, = jstarrc and jmacsrc as well.=20 KDE provides=20 a new alternative to kvt called konsole. To get the home/end keys to = work in=20 konsole you have to put:
=20
"\e[H":beginning-of-line
"\e[F":end-of-line

in .inputrc. Additionally, make sure that you have = checked=20 the 'BS sends DEL' checkbox (right mouse click, or through = the=20 'Options' pulldown menu). In kvt, KDE's home=20 and end can be configured by editing ~/.inputrc = (tcsh=20 users too, it uses readline):
=20
"\e[H":beginning-of-line
"\e[F":end-of-line

Less is ok on some systems. If it = is not on=20 yours, try the following. Create a file, /etc/lesskey, for=20 system-wide use. This will be a lesskey input file. Put the = following lines in the file:
#line-edit
\e[3~          delete
\e[1~          home
\e[4~          end


Save the file, and compile it as follows: =
[localhost]> lesskey -o /etc/less /etc/lesskey

Add the following line to /etc/profile:

export =
LESS=3D"-MM -k/etc/less"

Now type:

[localhost]> . /etc/profile

By fiddling with these settings you should be able to get less to = accept (all=20 of) the holy keycodes, at least, it works on my computer. For some = exciting=20 reading, check 'man=20 lesskey'.

Put the following in=20 ~/.Xdefaults:
 nedit.remapDeleteKey: =
False

Save the file, and the next time you start nedit the Delete = key will=20 do what we want it to: delete under the cursor. Note: you can also put = the line=20 in ~/.nedit, but every time you save the default settings, = the=20 .nedit file will be overwritten, and you'll have to (n)edit = it=20 again.

Note the nedit, as e.g. netscape, is a motif application. This means = that it=20 uses the XKeysymDB, see thet netscape section.

The keys should be ok, as = long as=20 the XKeysymDB is installed in one of the places where netscape looks = (where=20 netscape itself is installed, or /usr/X11R6/lib/X11/). = XKeysymDB is=20 similar to an xmodmap file, but with a very cryptic and poorly = documented=20 syntax. Luckily, it does do the delete/backspace thing right, so no = sweat.=20

If you use xmodmap, you may want to check out the graphical front end = for=20 X-keyboard configuration: xkeycaps. Get the .rpm at RedHat Powertools, or get = the Debian-p= ackage=20 (or plain tarball). It's a nice tool. You can also look for a default = Xmodmap=20 file on your system. At any rate, make sure that the following is in the = file:

keycode 22 =3D BackSpace
keycode 107 =3D Delete

alternatively, you can put it in e.g. your .Xclients file, or in=20 /etc/X11/xdm/Xsetup_0):

# map the [<---] =
key to the [BackSpace] keysym.
xmodmap -e "keycode 22 =3D BackSpace"
# map the [Delete] key to the [Delete] keysym.
xmodmap -e "keycode 107 =3D Delete"

I found that while the = keys worked=20 in a VT, in xterms only backspace works. This was caused by the=20 .Xdefaults modifications. If you use the = ~/.inputrc to=20 get Delete to work in xterms (and then pico and pine will be able to use = Delete), however, this creates problems with other apps (e.g. joe) which = cannot=20 be easily solved because joe relies on the .Xdefaults = modifications=20 to get the keys right. Anyway, it turns out that pine and pico are simply = broken, as=20 the workaround will clearly demonstrate. Admittedly broken is a relative = thing=20 in all this keyboard-confusion: from the other method's perspective they = are=20 perfectly ok. One thing is for sure, these two apps are exceptions. Try = the=20 following: make an expect script (let's call it picofix): =
#!/usr/bin/expect

eval spawn -noecho $argv

interact {
 \177        {send "\010"}
 "\033\[3~"  {send "\004"}
}

Make picofix executable, and start the editor (or pine) with =
picofix pico
and it will work (then you can make an alias or a wrapper). Thanks = to=20 Philip Hands for this ingenious (and powerful!) workaround. You can also = use an=20 alternate editor. Edit .pinerc and find the following = lines:=20

# Specifies the program invoked by ^_ in the Composer,
# or = the=20 "enable-alternate-editor-implicitly" feature.
editor=3D

You can enter the command for any editor here, e.g. joe = or=20 vi.

If you want the editor to be started right away, start = pine,=20 enter SETUP and Config and select the=20 enable-alternate-editor-implicitly option. Now the editor = of choice=20 will be started automagically when you start writing a message.

Pico fans may want to try jpico, which is basically joe with pico = keybindings=20 (and all the extra's joe offers). Others my be even smarter and switch = to vim and mutt.=20 Note that the first can be taught to do the Ctrl-j-trick, = the=20 latter can use pine keybindings.

Vim uses terminf= o, so=20 the keys should be ok if your terminfo is. However, if it is not, you = can still=20 get the keys to work in vim. Type :help fixdel in vim and = read all=20 about it.=20 Put the following line in=20 ~/.muttrc:
bind editor <delete> delete-char
This will make [Delete] do its job in mutt's internal pager.=20 If you have modified terminf= o and=20 you are e.g. telnetting to a machine with a default terminfo (for xterm=20 usually), you can use the following script (let's call it kbdfix) to = change the=20 keysequences you generate to the ones the program expects: =
#!/usr/bin/expect

eval spawn -noecho $argv

interact {
 \177        {send "\010"}
 "\033\[3~"  {send "\177"}
}

If you press [<---], expect will receive \177 (equivalent to = 0x7F and=20 ^?, see the VT220 = table)=20 and it will send \010 (equivalent to ^H) along to telnet, which will = result in=20 [<---] at the other end. Make it executable and use kbdfix = telnet=20 brokenhost. Thanks to Philip Hands for this clever workaround.=20

The logical next step is to automate the trick. Create a file,=20 /etc/broken-backspace-hosts (or a shorter name...). In this = file,=20 list the hosts which expect ^H and ^? instead of ^? and ^[[3~. Now you = can make=20 a wrapper for telnet as shown below. This particular script assumes that = the=20 telnet binary has been renamed telnet.orig, and that the kbdfix script = described=20 in the previous section is somewhere in your = path):

#!/bin/sh
if grep -wq "$@" /etc/broken-backspace-hosts ; then
 exec kbdfix telnet.orig "$@"
else
 exec telnet.orig "$@"
fi

From now on, when you use telnet, the script will check whether = the host=20 you are telnetting to is considered broken (listed in the=20 /etc/broken-backspace-hosts file). If it is, the expect script (kbdfix) = will be=20 used, if not, telnet will be started directly. You can do the same for = rlogin,=20 although rlogin can't be moved (i.e. won't work when it isn't called = rlogin).=20

This document was put together by Anne=20 Baretta (anne@ibb.net). Please mail me if you find mistakes, = tY-pO's,=20 alternative or plain better solutions. A few people have already pointed = out=20 many mistakes (there simply cannot be that many left...), which improved = the=20 document a lot. I=20 would like to thank all the people who contributed to the page, and = Thomas=20 Telkamp for hosting the site.

3D"page
This page is maintained by Anne Baretta (anne@ibb.net).
------=_NextPart_000_0000_01C63D78.F49A98A0 Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Content-Location: http://www.nedstat.nl/cgi-bin/nedstat.gif?name=keyboardtel R0lGODdhFgAWAPIAACAxQbRzi5S03pyUve4gMZzN/3O9/+b2/ywAAAAAFgAWAAADaXi63F4uxmJU uTjrXA8AW0gEV/eFmkAQpXKi2Cq0HggXw4iZNrxyLltuoAnodsHCakWMsYC1VSD3KxibyCjpsqRu eLMM9anhoarl5O2rXkNf7uxnTq/TKUG7fo4/xNkGgYKDhIUUhYiICQA7 ------=_NextPart_000_0000_01C63D78.F49A98A0 Content-Type: application/octet-stream Content-Transfer-Encoding: quoted-printable Content-Location: http://pagead2.googlesyndication.com/pagead/show_ads.js (function(){=0A= function m(b){return b!=3Dnull?'"'+b+'"':'""'}=0A= function B(b){if(typeof encodeURIComponent=3D=3D"function"){return = encodeURIComponent(b)}else{return escape(b)}}=0A= function c(b,a){if(a){window.google_ad_url+=3D"&"+b+"=3D"+a}}=0A= function g(b,a){if(a){c(b,B(a))}}=0A= function l(b,a,d){if(a&&typeof = a=3D=3D"object"){a=3Da[d%a.length]}c("color_"+b,a)}=0A= function D(b,a){var d=3Db.screen;var f=3Dnavigator.javaEnabled();var = e=3D-a.getTimezoneOffset();if(d){c("u_h",d.height);c("u_w",d.width);c("u_= ah",d.availHeight);c("u_aw",d.availWidth);c("u_cd",d.colorDepth)}c("u_tz"= ,e);c("u_his",history.length);c("u_java",f);if(navigator.plugins){c("u_np= lug",navigator.plugins.length)}if(navigator.mimeTypes){c("u_nmime",naviga= tor.mimeTypes.length)}}=0A= function = y(b){b=3Db.toLowerCase();if(b.substring(0,3)!=3D"ca-"){b=3D"ca-"+b}return= b}=0A= function = G(b,a,d){d=3Dd.substring(0,1000);d=3Dd.replace(/%\w?$/,"");if(b.google_ad= _output=3D=3D"js"&&(b.google_ad_request_done||b.google_radlink_request_do= ne)){a.write('