home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_04 / 2n04019a < prev    next >
Text File  |  1991-02-10  |  496b  |  24 lines

  1. /*
  2.  *  KEYS.C Copyright (C) 1990 by Mark R. Nelson
  3.  *
  4.  * This routine is used to read a character or extended character
  5.  * in from the keyboard.  It returns immediately if no character is
  6.  * available, returning a -1 to indicate no key.  A few of the
  7.  * extended key codes are defined in KEYS.H
  8.  */
  9. #include <conio.h>
  10.  
  11. int getkey()
  12. {
  13.     int c;
  14.  
  15.     if ( !kbhit())
  16.    return( -1 );
  17.     c = getch();
  18.     if ( c != 0 )
  19.    return( c );
  20.     else
  21.    return( getch() << 8 );
  22. }
  23.  
  24.