▲ | fc417fc802 a day ago | |||||||||||||
Also worth noting that many other ctrl-letter combinations map to signals in the terminal. In all the terminal emulators that I've used shift-ctrl-c & co are mapped by default for clipboard operations. | ||||||||||||||
▲ | mprovost a day ago | parent [-] | |||||||||||||
On terminals, the control key masked off the 6th and 7th bits of the 8-bit value sent by the letter key. That's a bitwise AND with octal 037, or in decimal subtracting 96 from the lower case key value. This happens in the terminal (or keyboard) itself, so the computer doesn't see it as two pressed keys, it just gets the masked value. In ASCII 'c' is 99 (decimal), so when modified with control is 3, ETX (end of text), which teletypes used to indicate the end of text. So unix shells reused that control character to terminate the current program with SIGINT. But every letter key maps to a control character at the start of the ASCII range, like 'g' maps to BEL for the bell, or 'h' maps to BS (backspace). '[' maps to ESC (escape) which is handy when Apple decides to move the escape key on their laptop keyboard. | ||||||||||||||
|