27 means you get ANSI escape sequences for arrows. They will be three-character sequences: 27, 91, and then 65, 66, 67, 68 (IIRC) for up, down, right, left. If you get 27 from a call to getchar() , then call it twice to get 91 , and a number indicating which arrow key was pressed.
As already mentioned, this is platform specific, but it may not matter to you.
Ernest Friedman-Hill Mar 09 '13 at 2:31 2013-03-09 02:31
source share