Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can't open because twitter, but here's own explanation:

Control-a inputs byte value 1, control-b 2 and so on.

BEL is mapped to value 7 in ascii, thus C-g.

Note control-space usually does input a NUL (0) in most terminals.



Another way to look at it is that Ctrl+G takes the code (ASCII) of G, i.e., 71 (binary 1000111) and toggles its 7th least significant bit to get 7 (binary 111) and indeed 7 is the code of the BEL character.

This explanation is over-simplified though. In practice, different systems have used different techniques to derive control codes from key chords. I have a more detailed article about this at https://susam.net/blog/control-escape-meta-tricks.html if anyone is interested to read it.


Producing ASCII control codes is why the Control code came to be and thats how it got its name:

https://en.wikipedia.org/wiki/Control_key#History




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: