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