Yes, the numeric code for escape is 27. Function and arrow keys give two numeric codes in a row, taking two iterations of the loop.

There may be a higher-level way of detecting them. Windows has virtual key codes. Are you making a console program or a gui program?

What do you mean by "navigate through the .exe file"?