What does an application read when the user press a backspace in the terminal in raw mode?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
In raw mode, if you type a character in the terminal, the application on the other side will read the ASCII code for the typed character.
But what about when you press the backspace key in the terminal, what would the application on the other side read?
terminal keyboard-shortcuts input control-characters
add a comment |Â
up vote
1
down vote
favorite
In raw mode, if you type a character in the terminal, the application on the other side will read the ASCII code for the typed character.
But what about when you press the backspace key in the terminal, what would the application on the other side read?
terminal keyboard-shortcuts input control-characters
2
Why don't you write a program to test it and find out?
â Stephen Harris
Nov 5 '17 at 20:55
2
@StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be^H
(0x08) whereas on othersDEL
(0x7F).
â egmont
Nov 5 '17 at 21:32
showkey -a
... in a terminal set to send a delete will display0x7F
forbackspace
... butCTRL backspace
will display 0x08 ...
â RubberStamp
Nov 5 '17 at 21:36
1
Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
â JdeBP
Nov 5 '17 at 22:11
@JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is â âÂÂit sends a control characterâ is the short answer here.
â Gilles
Nov 5 '17 at 23:12
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In raw mode, if you type a character in the terminal, the application on the other side will read the ASCII code for the typed character.
But what about when you press the backspace key in the terminal, what would the application on the other side read?
terminal keyboard-shortcuts input control-characters
In raw mode, if you type a character in the terminal, the application on the other side will read the ASCII code for the typed character.
But what about when you press the backspace key in the terminal, what would the application on the other side read?
terminal keyboard-shortcuts input control-characters
edited Nov 5 '17 at 23:31
Gilles
507k12010031532
507k12010031532
asked Nov 5 '17 at 20:48
user259116
191
191
2
Why don't you write a program to test it and find out?
â Stephen Harris
Nov 5 '17 at 20:55
2
@StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be^H
(0x08) whereas on othersDEL
(0x7F).
â egmont
Nov 5 '17 at 21:32
showkey -a
... in a terminal set to send a delete will display0x7F
forbackspace
... butCTRL backspace
will display 0x08 ...
â RubberStamp
Nov 5 '17 at 21:36
1
Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
â JdeBP
Nov 5 '17 at 22:11
@JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is â âÂÂit sends a control characterâ is the short answer here.
â Gilles
Nov 5 '17 at 23:12
add a comment |Â
2
Why don't you write a program to test it and find out?
â Stephen Harris
Nov 5 '17 at 20:55
2
@StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be^H
(0x08) whereas on othersDEL
(0x7F).
â egmont
Nov 5 '17 at 21:32
showkey -a
... in a terminal set to send a delete will display0x7F
forbackspace
... butCTRL backspace
will display 0x08 ...
â RubberStamp
Nov 5 '17 at 21:36
1
Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
â JdeBP
Nov 5 '17 at 22:11
@JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is â âÂÂit sends a control characterâ is the short answer here.
â Gilles
Nov 5 '17 at 23:12
2
2
Why don't you write a program to test it and find out?
â Stephen Harris
Nov 5 '17 at 20:55
Why don't you write a program to test it and find out?
â Stephen Harris
Nov 5 '17 at 20:55
2
2
@StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be
^H
(0x08) whereas on others DEL
(0x7F).â egmont
Nov 5 '17 at 21:32
@StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be
^H
(0x08) whereas on others DEL
(0x7F).â egmont
Nov 5 '17 at 21:32
showkey -a
... in a terminal set to send a delete will display 0x7F
for backspace
... but CTRL backspace
will display 0x08 ...â RubberStamp
Nov 5 '17 at 21:36
showkey -a
... in a terminal set to send a delete will display 0x7F
for backspace
... but CTRL backspace
will display 0x08 ...â RubberStamp
Nov 5 '17 at 21:36
1
1
Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
â JdeBP
Nov 5 '17 at 22:11
Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
â JdeBP
Nov 5 '17 at 22:11
@JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is â âÂÂit sends a control characterâ is the short answer here.
â Gilles
Nov 5 '17 at 23:12
@JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is â âÂÂit sends a control characterâ is the short answer here.
â Gilles
Nov 5 '17 at 23:12
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
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"?
No,stty
is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
â JdeBP
Nov 6 '17 at 7:02
stty erase
is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
â Stéphane Chazelas
Nov 6 '17 at 11:42
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
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"?
No,stty
is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
â JdeBP
Nov 6 '17 at 7:02
stty erase
is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
â Stéphane Chazelas
Nov 6 '17 at 11:42
add a comment |Â
up vote
2
down vote
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"?
No,stty
is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
â JdeBP
Nov 6 '17 at 7:02
stty erase
is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
â Stéphane Chazelas
Nov 6 '17 at 11:42
add a comment |Â
up vote
2
down vote
up vote
2
down vote
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"?
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"?
edited Nov 6 '17 at 11:26
answered Nov 5 '17 at 23:30
Gilles
507k12010031532
507k12010031532
No,stty
is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
â JdeBP
Nov 6 '17 at 7:02
stty erase
is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
â Stéphane Chazelas
Nov 6 '17 at 11:42
add a comment |Â
No,stty
is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.
â JdeBP
Nov 6 '17 at 7:02
stty erase
is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).
â Stéphane Chazelas
Nov 6 '17 at 11:42
No,
stty
is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.â JdeBP
Nov 6 '17 at 7:02
No,
stty
is not how one changes the terminal's behaviour. See my answer to the duplicate question, where this has already been answered including the correct way, for only some terminals, that one can change what the key sends.â JdeBP
Nov 6 '17 at 7:02
stty erase
is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).â Stéphane Chazelas
Nov 6 '17 at 11:42
stty erase
is to tell the line discipline which character is sent by your terminal upon the Backspace key. However, the line discipline doesn't use that information when in raw mode. That information is used to implement the LD's line editor (whereby upon receiving that character, it removes the last character from the line buffer as opposed to adding the ^H/^? to that edit line buffer, and the content of that buffer made available for reading by the application when ^J, eof, eol, eol2 characters are received).â Stéphane Chazelas
Nov 6 '17 at 11:42
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402720%2fwhat-does-an-application-read-when-the-user-press-a-backspace-in-the-terminal-in%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
Why don't you write a program to test it and find out?
â Stephen Harris
Nov 5 '17 at 20:55
2
@StephenHarris Probably because whatever happens on her/his computer is not necessarily universal. E.g. on some systems it might be
^H
(0x08) whereas on othersDEL
(0x7F).â egmont
Nov 5 '17 at 21:32
showkey -a
... in a terminal set to send a delete will display0x7F
forbackspace
... butCTRL backspace
will display 0x08 ...â RubberStamp
Nov 5 '17 at 21:36
1
Possible duplicate of How to allow backspaces in unbuffered/non-canonical mode?
â JdeBP
Nov 5 '17 at 22:11
@JdeBP This may be a duplicate, but not of that question. Here the question isn't about ^H vs ^? but about what the effect of the backspace key is â âÂÂit sends a control characterâ is the short answer here.
â Gilles
Nov 5 '17 at 23:12