home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!psuvax1!rutgers!uwvax!zazen!doug.cae.wisc.edu!castlab.engr.wisc.edu!chris
- From: chris@castlab.engr.wisc.edu (Christian Rohrmeier)
- Newsgroups: comp.lang.pascal
- Subject: Re: Read any key from the keyboard?
- Message-ID: <1992Sep1.105717.11923@doug.cae.wisc.edu>
- Date: 1 Sep 92 15:57:17 GMT
- References: <1992Sep1.123402.160@csghsg5a.bitnet>
- Organization: U of Wisconsin-Madison College of Engineering
- Lines: 53
-
- In article <1992Sep1.123402.160@csghsg5a.bitnet> 89612048s@csghsg5a.bitnet writes:
- >How to read any key from the keyboard?
- >
- >Can someone give me an example how to read any key pressed on the
- >keyboard. That means also the ALT SHIFT CONTROL and combinations
- >of these keys.
- >
- >And also, can you help me about the Num, Scrol and Capslock keys.
- >How to turn them on and off, and how to get there current status?
- >
- >I want to say thank you very much for your help.
- >
- >Yours Markus
-
- I can answer the 1st part of your question:
-
- function getkey:string;
-
- begin
- key:=readkey;
- getkey:=key;
- if key= chr(27) then getkey:='esc'
- else if key= #0 then begin
- key:= readkey;
- if key= 'I' then getkey:='pgup'
- else if key= 'Q' then getkey:='pgdn'
- else if key= 'O' then getkey:='end'
- else if key= 'G' then getkey:='home'
- else if key= 'H' then getkey:='up'
- else if key= 'P' then getkey:='down'
- else if key= 'K' then getkey:='left'
- else if key= 'M' then getkey:='rite'
- end;
- end;
-
- Ok, its not elegant, but it works (use case if you wanna.)
- The deal is, any non-normal key will return a #0 value the 1st readkey,
- and a letter value the next readkey you do (before anymore keys are hit.)
-
- So, looking back of your handy-dandy TP6.0 Programmer's Guide, page 350, will
- show you all the other letter equivilencies for all the ALT, CONTROL, and
- Function Key combinations.
-
- Some keys are not gonna give you the #0 code though, so just check for their
- numeric ASCII value with chr(x), as I did in the case of ESC (A complete ASCII
- chart is found on page 348).
-
- The other way to do this is to do some in-line assembler routine and use the Hex
- codes found (conveniently enough) on page 352!
-
- Enjoy.
-
- -Chris
-