I've been rediscovering ASCII control characters as I fiddled with some terminal emulation code, and wrote a small program that outputs the hex value of each key I press (tcsetattr() with ~ICANON).
While I understand pressing the keys Control and D simultaneously (CTL-D) generates the ASCII
0x04 control character, and a slew of others as nicely described on the WP ASCII page, I was surprised to see that (on OS X at least), some other unexpected keys generated control chars as well:
CTL-2/@ = NUL = ^@ = 0x00 (expected actually) CTL-3/# = ESC = ^[ = 0x1B CTL-4/$ = FS = ^\ = 0x1C CTL-5/% = GS = ^] = 0x1D CTL-6/^ = RS = ^^ = 0x1E (expected actually) CTL-7/& = CTL-/ = US = ^_ = 0x1F CTL-8/* = DEL = ^? = 0x7F
Note that CTL-1, -9, and -0 don't generate control characters, just the normal digit.
Except for those two expected chars (NUL and RS), why do terminals generate control characters for this subset of number keys?
Edit: to be clear, I'm aware and understand that CTL-[=Esc, and the other standard "caret"/control keys (^\, ^], ^^, ^_, ^?). I'm wondering about why the number or ^#,^$,^%,^&,^* and ^/ control keys overlap with them.