home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!paladin.american.edu!news.univie.ac.at!email!ps1.iaee.tuwien.ac.at!Sorokin
- From: Sorokin@ps1.iaee.tuwien.ac.at (Sorokin Zhenya)
- Subject: Re: how to get keys
- Message-ID: <Sorokin.46.726163321@ps1.iaee.tuwien.ac.at>
- Lines: 92
- Sender: news@email.tuwien.ac.at
- Nntp-Posting-Host: pc77.iaee.tuwien.ac.at
- Organization: Inst. of General Electronics and Electroengeneering, TU Vienna
- References: <19926.4410.10386@dosgate> <1992Dec6.234052.379@et.tudelft.nl> <1992Dec7.091803.4299@alf.uib.no>
- Distribution: comp
- Date: Mon, 4 Jan 1993 16:02:01 GMT
- Lines: 92
-
- In article <1992Dec7.091803.4299@alf.uib.no> yngvar@novaja.imr.no (Yngvar Foelling) writes:
- >From: yngvar@novaja.imr.no (Yngvar Foelling)
- >Subject: Re: how to get keys
- >Date: Mon, 7 Dec 92 09:18:03 GMT
- >In article <1992Dec6.234052.379@et.tudelft.nl>, mvdl@et.tudelft.nl writes:
- >|> In article <19926.4410.10386@dosgate>, "andrew makiejewski" <andrew.makiejewski@canrem.com> writes:
- >|> >
- >|> > Hi everyone, I have a question. I need to know if there is some simple
- >|> > way to do the following. I want to pass as a parameter to a procedure
- >|> > that will indicate what keypresses are valid. I am doing this already
- >|> > for regular keys, but I need to be able to list regular keys as well as
- >|> > extended key(mostly function keys).
- >|> >
- >|> > I do like so,
- >|> >
- >|> > Command_Keys : Set of Char ['Q', 'A', 'K'];
- >|> > Is there a way to add extended keys to the above.
- >|>
- >|> Using SCANCODES you can detect any key that's being pressed.. either by hooking
- >|> a scancode-read-procedure on int-$09 or even with the 'keypressed' statement...
- >|>
- >|> Scancodes are:
- >|>
- >|> --------------- cut cut -----------------
- >|> ^INT 16 - Keyboard Scan Codes
- >|>
- >|> % Key Normal Shifted w/Ctrl w/Alt
- >|>
- >|> A 1E61 1E41 1E01 1E00
- >
- > [Rest of list and description of INT 16H call deleted.]
- >
- >NO, NO, NO! Please DON'T assume the scan codes for the normal ASCII codes!
- >It creates nightmares for us who don't use American keyboards.
- >
- >Sorry about that, but I've had enough trouble with software making my computer
- >go haywire unless I switch to the American layout, which of course doesn't fit
- >the markings on the keys. It also automatically precludes the use of non-
- >English characters, such as the one in my name.
- >
- >The only reason I see for doing this, is to distinguish the duplicated keys,
- >most of whom are on the numeric keypad. First ask yourself if you want to
- >distinguish them (you better have a *good* reason). If your answer is yes,
- >only assume the scan codes for thecharacters on the keypad, and assume that
- >anything else is on the normal keyboard.
- >
- >The method I use is to write a wrapper function returning Integer. Sorry, I
- >don't have a PC in front of me, and I do most of my programming in C, so
- >this may contain mistakes:
- >
- >function GetExtendedKey : Integer;
- >var
- > Key : Char;
- >begin
- > Key := ReadKey; { Is this the correct name of the function? }
- > if Key = #0 then
- > GetExtendedKey := Ord(ReadKey) + 256
- > else
- > GetExtendedKey := Ord(Key);
- >end;
- >
- >To test for extended characters, just check if the returned value is greater
- >than or equal to 256. Otherwise use Chr to convert the value back to a
- >character.
- >
- >The original poster would need to make his set
- >
- >set of [0..511];
- >
-
- No, this wouldn't work. Type "set" is limited to 256 entries.
- Either you add 128 and drive all non-english users crazy, or just give up
- using sets.
-
-
- >and add Ord('Q'), Ord('A') etc. to it, along with the codes for the extended
- >keys.
- >
- >Note, I know that this method is not uncommon, but I've often seen code that
- >adds 128 instead of 256, to make the returned value fit in a byte. My teeth
- >start gnashing again. One thing is that this makes it impossible to distin-
- >guish characters in the extended character set from extended keys like func-
- >tion keys (note the difference), but there are also extended keys with scan
- >codes higher than 128.
- >
- >--
- >ISO 8859-1: Yngvar F°lling | Snail mail:
- >ASCII: Yngvar Foelling | Tertnesveien 121
- > | N-5084 Tertnes
- >E-mail: yngvar@imr.no | Norway
-
- Yours,
-