The 27
implies that you're getting ANSI escape sequences for the arrows. They're going to be three-character sequences: 27, 91, and then 65, 66, 67, 68 (IIRC) for up, down, right, left. If you get a 27
from a call to getchar()
, then call it twice more to get the 91
and the number that determines what arrow key was pressed.
As someone else mentioned, this is platform-specific, but you may not care.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…