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

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!paladin.american.edu!news.univie.ac.at!email!ps1.iaee.tuwien.ac.at!Sorokin
  3. From: Sorokin@ps1.iaee.tuwien.ac.at (Sorokin Zhenya)
  4. Subject: Re: how to get keys
  5. Message-ID: <Sorokin.46.726163321@ps1.iaee.tuwien.ac.at>
  6. Lines: 92
  7. Sender: news@email.tuwien.ac.at
  8. Nntp-Posting-Host: pc77.iaee.tuwien.ac.at
  9. Organization: Inst. of General Electronics and Electroengeneering, TU Vienna
  10. References: <19926.4410.10386@dosgate> <1992Dec6.234052.379@et.tudelft.nl> <1992Dec7.091803.4299@alf.uib.no>
  11. Distribution: comp
  12. Date: Mon, 4 Jan 1993 16:02:01 GMT
  13. Lines: 92
  14.  
  15. In article <1992Dec7.091803.4299@alf.uib.no> yngvar@novaja.imr.no (Yngvar Foelling) writes:
  16. >From: yngvar@novaja.imr.no (Yngvar Foelling)
  17. >Subject: Re: how to get keys
  18. >Date: Mon, 7 Dec 92 09:18:03 GMT
  19. >In article <1992Dec6.234052.379@et.tudelft.nl>, mvdl@et.tudelft.nl writes:
  20. >|> In article <19926.4410.10386@dosgate>, "andrew makiejewski" <andrew.makiejewski@canrem.com> writes:
  21. >|> > 
  22. >|> > Hi everyone, I have a question. I need to know if there is some simple
  23. >|> > way to do the following. I want to pass as a parameter to a procedure
  24. >|> > that will indicate what keypresses are valid. I am doing this already
  25. >|> > for regular keys, but I need to be able to list regular keys as well as
  26. >|> > extended key(mostly function keys).
  27. >|> > 
  28. >|> > I do like so,
  29. >|> > 
  30. >|> > Command_Keys : Set of Char ['Q', 'A', 'K'];
  31. >|> > Is there a way to add extended keys to the above.
  32. >|> 
  33. >|> Using SCANCODES you can detect any key that's being pressed.. either by hooking
  34. >|> a scancode-read-procedure on int-$09 or even with the 'keypressed' statement...
  35. >|> 
  36. >|> Scancodes are:
  37. >|> 
  38. >|> --------------- cut cut -----------------
  39. >|> ^INT 16 - Keyboard Scan Codes
  40. >|>  
  41. >|> %              Key       Normal    Shifted   w/Ctrl    w/Alt
  42. >|>  
  43. >|>                 A         1E61      1E41      1E01      1E00
  44. >
  45. >   [Rest of list and description of INT 16H call deleted.]
  46. >
  47. >NO, NO, NO!  Please DON'T assume the scan codes for the normal ASCII codes!
  48. >It creates nightmares for us who don't use American keyboards.
  49. >
  50. >Sorry about that, but I've had enough trouble with software making my computer
  51. >go haywire unless I switch to the American layout, which of course doesn't fit
  52. >the markings on the keys.  It also automatically precludes the use of non-
  53. >English characters, such as the one in my name.
  54. >
  55. >The only reason I see for doing this, is to distinguish the duplicated keys,
  56. >most of whom are on the numeric keypad.  First ask yourself if you want to
  57. >distinguish them (you better have a *good* reason).  If your answer is yes,
  58. >only assume the scan codes for thecharacters on the keypad, and assume that
  59. >anything else is on the normal keyboard.
  60. >
  61. >The method I use is to write a wrapper function returning Integer.  Sorry, I
  62. >don't have a PC in front of me, and I do most of my  programming in C, so
  63. >this may contain mistakes:
  64. >
  65. >function GetExtendedKey : Integer;
  66. >var
  67. >  Key : Char;
  68. >begin
  69. >  Key := ReadKey;    { Is this the correct name of the function? }
  70. >  if Key = #0 then
  71. >    GetExtendedKey := Ord(ReadKey) + 256
  72. >  else
  73. >    GetExtendedKey := Ord(Key);
  74. >end;
  75. >
  76. >To test for extended characters, just check if the returned value is greater
  77. >than or equal to 256.  Otherwise use Chr to convert the value back to a
  78. >character.
  79. >
  80. >The original poster would need to make his set
  81. >
  82. >set of [0..511];
  83. >
  84.  
  85. No, this wouldn't work. Type "set" is limited to 256 entries. 
  86. Either you add 128 and drive all non-english users crazy, or just give up 
  87. using sets.
  88.  
  89.  
  90. >and add Ord('Q'), Ord('A') etc. to it, along with the codes for the extended
  91. >keys.
  92. >
  93. >Note, I know that this method is not uncommon, but I've often seen code that
  94. >adds 128 instead of 256, to make the returned value fit in a byte.  My teeth
  95. >start gnashing again.  One thing is that this makes it impossible to distin-
  96. >guish characters in the extended character set from extended keys like func-
  97. >tion keys (note the difference), but there are also extended keys with scan
  98. >codes higher than 128.
  99. >
  100. >-- 
  101. >ISO 8859-1: Yngvar F°lling  | Snail mail:
  102. >ASCII:      Yngvar Foelling | Tertnesveien 121
  103. >                            | N-5084 Tertnes
  104. >E-mail:     yngvar@imr.no   | Norway
  105.  
  106. Yours,
  107.