🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #606

Re: How to test for a key ALREADY pressed?

#606
From: Denis Beauregard
Date: Wed, 08 Apr 1992 01:00
31 lines
1845 bytes
In article <rqjbpINNiqv@matt.ksu.ksu.edu> kentiler@matt.ksu.ksu.edu (Kent Iler) writes:
>Hello,
>   Is there a way to test to see if a key is already pressed.  Let say I run
>this program from the autoexec, and I want to see if the space bar is pressed.
>If it is I want to do one thing, if not I want to do another.  I don't want to
>wait there for a key to be pressed, just see if it already is.  I have C++ and
>Turbo Pascal to program with.  Thanks.
>						--Kent

The wire in front of your keyboard is a communication line.
Each time you depress and release a key, you sent a message to the PC.
Thus, if you don't watch that line, you cannot know the current state
of keys.

There are 2 exceptions : shift/alt/ctrl group and toggle group.
Keyboard routine will remember in 8 bits the state of left-shift, right-shift,
alt or ctrl keys, as well as caps-lock, num-lock, insert and scroll-lock.

So, instead of using space bar, just use other keys, and you are in business!

Check the keyboard BIOS routine to know (in keyboard status routine)
which bit does what.

Reference : Int 16h, function 02, return keyboard flags.


-- 
    Denis Beauregard       _ _ _ _  Collecting Beauregard/Jarret/Jarest/Vincent
beaurega@ireq.hydro.qc.ca | * | * | Promoting use of QC as Quebec Postal Code
  Andre Jarret, sieur de  |===|===| Mes opinions?  Oui, oui, les miennes!
   Beauregard 1642-1992   |_*_|_*_| My opinions?  Yes, yes, mine!
Technical Details
Message-ID: <9682@s3.ireq.hydro.qc.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!bonnie.concordia.ca!s3!beaurega
References: <rqjbpINNiqv@matt.ksu.ksu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!bonnie.concordia.ca!s3!beaurega
From: beaurega@ireq.hydro.qc.ca (Denis Beauregard)
Newsgroups: comp.os.msdos.programmer
Subject: Re: How to test for a key ALREADY pressed?
Message-ID: <9682@s3.ireq.hydro.qc.ca>
Date: 8 Apr 92 01:00:44 GMT
References: <rqjbpINNiqv@matt.ksu.ksu.edu>
Sender: usenet@s3.ireq.hydro.qc.ca
Organization: Hydro-Quebec
Lines: 31