home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / pascal / 7956 < prev    next >
Encoding:
Text File  |  1993-01-07  |  1.3 KB  |  46 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!mcsun!fuug!pcuf!news
  3. From: basse@pcuf.fi (Basse Salmela)
  4. Subject: Re: Cursor and F1-F12 keys under Turbo-Pascal
  5. Message-ID: <C0GEC9.62q@pcuf.fi>
  6. Sender: news@pcuf.fi (News)
  7. Nntp-Posting-Host: pcuf.fi
  8. Organization: The PC-users of Finland
  9. References: <1993Jan4.134821.325@sinus.stgt.sub.org>
  10. Date: Wed, 6 Jan 1993 22:26:32 GMT
  11. Lines: 33
  12.  
  13.   You wanted to know how to use function and cursor keys in your Pascal
  14. programs.
  15.   
  16.   When reading cursor keys, and function keys, you have to read character
  17. twice. In first time when key is pressed the return is character #0, after
  18. that comes second character, example #59 which is F1.
  19.   Maybe a little example makes it easier to understand.
  20.   
  21.   Ch := ReadKey;
  22.   If Ch = #0 then Begin
  23.     Ch := ReadKey;
  24.     Case Ch of
  25.       #59 : F1Pressed;
  26.       #60 : F2Pressed;
  27.     End;
  28.   End;
  29.   
  30.   There, in first 'ch := readkey' program asks user to press any key, and
  31. if it was #0 then it reads the second char what comes automaticly after
  32. #0 and then comes that Case loop..
  33.   
  34.   Finding out these combinations you should do a program which shows every
  35. key code you press. Something like this:
  36.   
  37.   Repeat
  38.    Ch := ReadKey;
  39.    WriteLn('Key was: ', Ord(Ch));
  40.   Until Ch = #27;
  41.   
  42.   
  43.   Hope this helped in some way...
  44.   
  45.     Best regards, BaSSe
  46.