Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!njin!njitgw.njit.edu!mars.njit.edu!cd5340 From: cd5340@mars.njit.edu (David Charlap) Newsgroups: comp.lang.pascal Subject: Re: CTRL-Characters Message-ID: <1991Mar28.082147.28971@njitgw.njit.edu> Date: 28 Mar 91 08:21:47 GMT References: <1991Mar27.160905.1962@cs.mcgill.ca> <1991Mar27.161213.2100@cs.mcgill.ca> Sender: root@njitgw.njit.edu (System PRIVILEGED Account) Organization: New Jersey Institute of Technology Lines: 31 Nntp-Posting-Host: mars.njit.edu In article <1991Mar27.161213.2100@cs.mcgill.ca> storm@cs.mcgill.ca (Marc WANDSCHNEIDER) writes: > > >How do I make a PASCAL program recognize CTRL characters (or ALT characters >for that matter). Ie I want the following: > > IF CH = CTRL-G then > BEGIN > blahblahb > END; Simple. Ctrl-Codes are ascii values 1-31 representing ^A-^_. Note that certain special keys "map" onto other Control codes. For example: ^M==Ascii 13, ^I==Ascii 9, ^[==Ascii 27, etc. So, your example would be: Var Ch : Char; ... If Ch = #7 then..... To scan for an Alt-Key, you need to use Turbo Pascal's extended scan codes. If the character read is ASCII-0 (#0), then the key pressed is a special "extended" key. The next "Character" read will be the extended key code. Consult the chart in the back of your manual for the extended codes. It's on page 424 in the Turbo Pascal 5.0 reference guide. -- David Charlap "Invention is the mother of necessity" cd5340@mars.njit.edu "Necessity is a mother" Operators are standing by "mother!" - Daffy Duck