home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_09 / 2n09046a < prev    next >
Text File  |  1991-07-23  |  1KB  |  62 lines

  1.  
  2. /*
  3.  *  testkeys.c:
  4.  *
  5.  *  Test program for Tom Wurzbach's extended
  6.  *  scancodes function package
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <dos.h>
  11.  
  12. extern int getkey(void);
  13. extern int getshift(void);
  14. extern int kbhit(void);
  15.  
  16. union KEY
  17. {
  18.     char   ASCII_code;
  19.     int    scan_code;
  20. };
  21.  
  22. union SHIFT
  23. {
  24.     int    shift;
  25.     struct
  26.     {
  27.         unsigned rshift      : 1;
  28.         unsigned lshift      : 1;
  29.         unsigned ctrl        : 1;
  30.         unsigned alt         : 1;
  31.         unsigned scroll      : 1;
  32.         unsigned num         : 1;
  33.         unsigned caps        : 1;
  34.         unsigned ins         : 1;
  35.     } bit;
  36. };
  37.  
  38. main()
  39. {
  40.     union KEY k;
  41.     union SHIFT s;
  42.  
  43.     puts("Press keys, Ctrl-Break to exit");
  44.  
  45.     while (1) 
  46.        {
  47.        k.scan_code = getkey();
  48.        s.shift = getshift();
  49.        printf("0x%04x   0x%02x   ", k.scan_code, k.ASCII_code);
  50.        if (s.bit.rshift) printf("RShift  ");
  51.        if (s.bit.lshift) printf("LShift  ");
  52.        if (s.bit.ctrl) printf("Ctrl  ");
  53.        if (s.bit.alt) printf("Alt  ");
  54.        if (s.bit.scroll) printf("Scroll  ");
  55.        if (s.bit.num) printf("Num  ");
  56.        if (s.bit.caps) printf("Caps  ");
  57.        if (s.bit.ins) printf("Ins  ");
  58.  
  59.        printf("\n");
  60.        }
  61. }
  62.