Actually, if you type a character in a terminal, the application will read that character.
Well, more precisely, if you type a character in a terminal, it's converted to one or more bytes — most modern Unix system use the UTF-8 encoding of characters. The application reads those bytes and reassembles the characters. This is still not ASCII codes — ASCII is a 7-bit encoding, so all characters in the ASCII character set fit in one byte.
When you type a function or cursor key such as BackSpace, Tab, Return, F1, Left, etc., it's encoded as a control character or an escape sequence. There are a few control characters that correspond to function keys, such as ^I (byte value 9) for Tab and ^M (byte value 13) for Return. Most other function keys send an escape sequence beginning with the escape character (^[, byte value 27).
BackSpace sends a control character. For historical reasons, which control character it sends depends on the terminal and on its configuration: it can be either ^H (byte value 8) or ^? (byte value 127). On many modern terminals, you can change this in the configuration; see How to allow backspaces in unbuffered/non-canonical mode?. In case the setting isn't picked up automatically, you can declare it with stty
.
For more background, see How do keyboard input and text output work? and How to make a comprehensive set of possibilities for defining GNU-screen "command characters"?
^H
(0x08) whereas on othersDEL
(0x7F). – egmont Nov 05 '17 at 21:32showkey -a
... in a terminal set to send a delete will display0x7F
forbackspace
... butCTRL backspace
will display 0x08 ... – RubberStamp Nov 05 '17 at 21:36