<HTML ><HEAD ><TITLE >Why It Doesn't (Always) Work</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ "><LINK REL="HOME" TITLE="Linux Backspace/Delete mini-HOWTO" HREF="index.html"><LINK REL="PREVIOUS" TITLE="How Keys Are Turned Into Actions" HREF="actions.html"><LINK REL="NEXT" TITLE="X" HREF="x.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Linux <B CLASS="KEYCAP" >Backspace</B >/<B CLASS="KEYCAP" >Delete</B > mini-HOWTO</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="actions.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="WHY">3. Why It Doesn't (Always) Work</H1 ><P >I hope the basic problem is clear at this point: there is a bottleneck between the keyboard and console applications, that is, the fact that they can only communicate by <SPAN CLASS="ACRONYM" >ASCII</SPAN > sequences. So special keys must be first translated from keysyms to sequences, and then from sequences to key capabilities. Since different consoles have different ideas about what this translation can look like, we need a terminal database. The system would work flawlessly, except for a small problem: it is not always set up correctly, and not everyone uses it. </P ><P >Applications must have a way to know which database entry to use: this is accomplished by suitably setting the <TT CLASS="ENVAR" >TERM</TT > environment variable. In some cases, there is a mismatch between the terminal emulator and the content of the database entry suggested by <TT CLASS="ENVAR" >TERM</TT >.</P ><P >Moreover, many applications <EM >do not use</EM > the terminal database (or at least not all of it), and consider <SPAN CLASS="SYMBOL" >BS</SPAN > and <SPAN CLASS="SYMBOL" >DEL</SPAN > <SPAN CLASS="ACRONYM" >ASCII</SPAN > codes with an intended meaning: thus, without looking at the database, they assign them semantics (usually, of course, the semantics is removing the character before or under the cursor). So now our beautiful scheme is completely broken (as every Linux user is bitterly aware). For instance, the <SPAN CLASS="APPLICATION" >bash</SPAN > assumes that <SPAN CLASS="SYMBOL" >DEL</SPAN > should do a <SPAN CLASS="ACTION" >backward-delete-char</SPAN >, that is, backspace. Hence, on a fresh install the <B CLASS="KEYCAP" >Backspace</B > key works on the console as expected, but just because of two twists in a row! Of course, the <B CLASS="KEYCAP" >Delete</B > key does not work. This happens because the <SPAN CLASS="APPLICATION" >bash</SPAN > does not look into the terminal database for the <TT CLASS="LITERAL" >kdch1</TT > capability.</P ><P >Just to illustrate how things have become entangled, consider the <B CLASS="COMMAND" >fix_bs_and_del</B > script provided with the Red Hat distribution (and maybe others). It assigns on-the-fly the <SPAN CLASS="KEYSYM" >BackSpace</SPAN > keysym to the <B CLASS="KEYCAP" >Backspace</B > key, and the <SPAN CLASS="KEYSYM" >Delete</SPAN > keysym to the <B CLASS="KEYCAP" >Delete</B > key. Now the shell works! Unfortunately, all programs relying on the correct coupling of keysym generation and terminal database mappings are now not working at all, as the <SPAN CLASS="KEYSYM" >Delete</SPAN > keysym is mapped to <SPAN CLASS="SYMBOL" >DEL</SPAN >, and the latter to the <TT CLASS="LITERAL" >kbs</TT > key capability by the terminfo database, so in such programs both keys produce backspacing.</P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="actions.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="x.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >How Keys Are Turned Into Actions</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >X</TD ></TR ></TABLE ></DIV ></BODY ></HTML >