home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20039 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  1.5 KB

  1. Xref: sparky comp.lang.c:20039 comp.os.msdos.programmer:12322
  2. Newsgroups: comp.lang.c,comp.os.msdos.programmer
  3. Path: sparky!uunet!cs.utexas.edu!uwm.edu!linac!att!cbnewse!cbnewsd!att-out!cbfsb!cbnewsg.cb.att.com!rnichols
  4. From: rnichols@cbnewsg.cb.att.com (robert.k.nichols)
  5. Subject: Re: Reading the arrow keys... how?
  6. Message-ID: <1993Jan22.010607.15208@cbfsb.cb.att.com>
  7. Sender: news@cbfsb.cb.att.com
  8. Organization: AT&T
  9. References: <1jmeupINN4g9@savoy.cc.williams.edu>
  10. Date: Fri, 22 Jan 1993 01:06:07 GMT
  11. Lines: 26
  12.  
  13. In article <1jmeupINN4g9@savoy.cc.williams.edu> 93gke@williams.edu (Just Ask The Axis) writes:
  14. >I am trying to read the arrow keys from a PC keyboard in C. So far
  15. >the calls to getch(), getc(), getchar(), have been unsuccessful
  16. >because the keys don't seem to have a corresponding ASCII code (they
  17. >seem to send 2 characters..?) I also need to read some regular keys
  18. >like Q,S, etc... 
  19.  
  20. You can use getch() to read the arrow keys.  The extended keys all
  21. return a 2-byte sequence, with the first byte being either 0 or 0xE0.
  22. When you see one of those values, the next call to getch() will return
  23. a code that indicates the key.  Header file EXTEND.H, if you have it,
  24. contains definitions for the key codes -- I don't recall where I dug
  25. them up.  Here are a few values:
  26.  
  27.     #define HOME         71
  28.     #define CTRL_HOME   119
  29.     #define END          79
  30.     #define CTRL_END    117
  31.     #define ARROW_UP     72
  32.     #define ARROW_DOWN   80
  33.     #define ARROW_LEFT   75
  34.     #define ARROW_RIGHT  77
  35.  
  36. Bob Nichols
  37. AT&T Bell Laboratories
  38. rnichols@ihlpm.ih.att.com
  39.