home *** CD-ROM | disk | FTP | other *** search
- /*
- * GetKey () is yet another replacement for getch ().
- * This is about a quick and dirty as it gets.
- *
- * If no character is waiting GetKey () returns 0.
- * If an ASCII character is waiting it returns the ASCII value and removes
- * the keystroke from the keyboard buffer
- * If it's an extended code it converts the code to a negative IE: F1 = -59
- * and returns the negative value. The keystroke is remove from the
- * keyboard buffer.
- *
- * (GetKey () == 0) The no keystrokes waiting
- * (GetKey () < 0) An extended code was converted to a
- * negative and returned
- * (GetKey () > 0) The ASCII code was returned.
- */
-
- int GetKey (void);
-
- int GetKey (void)
- {
- int iRetKeyVal;
- if (!kbhit ())
- {
- return 0x00;
- }
- return (((iRetKeyVal = getch ()) != 0x00) ? iRetKeyVal : getch () * -1);
- }
-