Category : A Collection of Games for DOS and Windows
Archive   : DUI.ZIP
Filename : KEYBOARD.INC

 
Output of file : KEYBOARD.INC contained in archive : DUI.ZIP
{
---- K E Y B O A R D ----

These routines will let you detect, and control, the various shift states of
the stardard PC keyboard (I don't know if they work on an AT, JR, or clone).

The function "KeyChk" will check the state of the specified key, and return
either TRUE of FALSE. The procedure "KeySet" will accept a key, and a state
(TRUE or FALSE), and will set the key to that state.

The key definitions are as follows:

LshDep - Is the left shift key depressed?
RshDep - Is the right shift key depressed?
CtlDep - Is the CTRL key depressed?
AltDep - Is the ALT key depressed?
ScrDep - Is ScrollLock depressed? ScrLok - Are we in ScrollLock state?
NumDep - Is NumLock depressed? NumLok - Are we in NumLock state?
CapDep - Is CapsLock depressed? CapLok - Are we in CapsLock state?
InsDep - Is Insert depressed? InsMod - Are we in Insert mode?

All states are checkable, but only the "___Lok" states can be meaningfully
set; I don't know what happens if you try to set a "___Dep" state (Norton
says it's "potentially very disruptive" to do so...)

--------- Examples ---------

Suppose we want to make the PC work like a standard typewriter, such that
if you press a SHIFT key, it turns off CapsLock. Just insert the following
code at some point where it will execute fairly often:

If (KeyChk(LshDep) or KeyChk(RshDep)) and KeyChk(CapLok)
Then KeySet(CapLok, False);

Or, suppose we just want to harass those people who leave the keyboard in
NUMLOCK state. How's this for user-hostile software:

If KeyChk(NumLok)
Then Sound(50+Random(800))
Else NoSound;

Makes it sound like you've got hornets in your hard disk!

-------------------------------------------------------------------------------
Public Domain, Mark VanTassel, 9/11/86
-------------------------------------------------------------------------------
}

Type K_Type=(RshDep, LshDep, CtlDep, AltDep, ScrLok ,NumLok ,CapLok, InsMod,
Kjunk1, Kjunk2, Kjunk3, Kjunk4, ScrDep, NumDep, CapDep, InsDep);
Var K_Bits:Set of K_Type Absolute $0000:$0417;


Procedure KeySet(Key:K_Type; TF:Boolean);
Begin
If TF
Then K_Bits := K_Bits + [Key]
Else K_Bits := K_Bits - [Key];
End;

Function KeyChk(Key:K_Type):Boolean;
Begin
KeyChk := Key in K_Bits;
End;


  3 Responses to “Category : A Collection of Games for DOS and Windows
Archive   : DUI.ZIP
Filename : KEYBOARD.INC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/