home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list14_6.c < prev    next >
C/C++ Source or Header  |  1993-10-16  |  626b  |  37 lines

  1.  /* Demonstrates reading extended keys from the keyboard. */
  2.  
  3.  #include <stdio.h>
  4.  #include <conio.h>
  5.  
  6.  int ext_key(void);
  7.  
  8.  main()
  9.  {
  10.      int ch;
  11.  
  12.      puts("Press any extended key; press F1 to exit.");
  13.  
  14.      while (1)
  15.      {
  16.          ch = ext_key();
  17.          if (ch == 59)      /* F1? */
  18.              break;
  19.          else
  20.              printf("\nThat key's code has a value of %d.", ch);
  21.      }
  22.  }
  23.  
  24.  int ext_key(void)
  25.  {
  26.      int ch;
  27.  
  28.      /* Wait until a zero byte comes in. */
  29.  
  30.      while ((ch = getch()) != 0)
  31.          ;
  32.  
  33.      /* Return the next character. */
  34.  
  35.      return getch();
  36.  }
  37.