From: "Chris Broome" Newsgroups: comp.os.msdos.djgpp References: <4661cac DOT 3622aaa3 AT aol DOT com> Subject: Re: Detecting Arrow key presses Lines: 32 X-Newsreader: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Message-ID: Date: Tue, 13 Oct 1998 01:00:11 -0500 NNTP-Posting-Host: 166.55.87.171 X-Trace: news.cwix.com 908258025 166.55.87.171 (Tue, 13 Oct 1998 05:53:45 GMT) NNTP-Posting-Date: Tue, 13 Oct 1998 05:53:45 GMT Organization: CWIX To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com DoctorXV AT aol DOT com wrote in message <4661cac DOT 3622aaa3 AT aol DOT com>... >how do I get C++ to detect arrow key presses? I use Turbo C++ 3.0 This works very well in a loop: #include /* These are just a few ASCII values for the keys hit.*/ #define ENTER 13 #define ESC 27 #define UP 72 #define DOWN 80 #define LEFT 75 #define RIGHT 77 #define BACKSPACE 8 #define TAB 9 #define SPACE 32 void main() { char key; while(SomeCondition) { if (kbhit()) /* first detect if the keyboard was hit */ { key=getch(); /* if it was, then get what key was hit */ if (key==UP) .... /* if up was hit, do something*/ } } }