Back in my days of Turbo Pascal 6 I once created a small program to reveal the key codes of all keys, including function keys, escape keys, arrow keys. I imagine you can do that too in C++. I think you can use getch() from ... the dontremembertheheader.h (hehe, I think it is stdio.h), or see if you can use std::cin.get() from the STL (#include <iostream>). There are other libraries for console input/output too, if you care to check them out.
Basically you use those functions in a loop and you print the code value on screen and voilá! I think the ESC key is code 27.
BTW, all that for a console application. If not a console application, I can only provide guidance for a Windows application.