When I run the following program:
int main()
{
getchar();
return 0;
}
And I press any of the arrow keys like ↑ (up arrow) on the console I get ^[[A
. I want to know what this means. Specifically, I want to know what ^[
means.
The ^
is a shorthand notation for Ctrl key. Then ^[
is a terminal escape code for ESC
, the escape character.
A caret character in front of another character is an escape sequence for a control character (one of the characters with code points 0 to 31). ^[ is an escape character named ESC and usually introduces escape sequences for your terminal. This is what your keyboard sends when you hit the up arrow.