How are control keys obtained from the NCurses library? I need to know if a result from getch ()
is a character pressed with ctrl, and what character was pressed with it. I googled "ctrl keys ncurses" and "control keys ncurses" without much results.
I know from a quick test that (at least in my case) all the CTRL characters are related to the characters by a difference of 96.
ie
akey is 97
^Akey is 1
bkey is 98
^Bkey is 2
ckey is 99
^Ckey is 3
But this doesn't seem like reliable information to write a program with. Does anyone know a way of doing this?
That actually is reliable (but with 64, not 96). Ctrl+A all the way through Ctrl-_ are handled properly (use of Ctrl-@ is discouraged due to other meanings of NUL).