home *** CD-ROM | disk | FTP | other *** search
- I used Peter Norton's "Programmer's Guide to the IBM PC
- & PS/2", copyright 1988, published by Microsoft press,
- as the only reference in coding pckey.
-
- The PCKey class provides access to the PC's keyboard through
- fast inline member functions. Special characters are
- defined in the header for your convenience. PCKey is not
- for use in Windows 3.0 programming -- use only for DOS
- applications!
-
- Compile and run fastkey.cpp to set your keyboard's fastest
- typematic rate/delay.
-
- Define TEST_PCKEY_CPP near the end of pckey.cpp to test the
- pckey.cpp module in a stand alone fashion. Study the code
- in main() for an example of using the PCKey class.
-
- Never instantiate any instance of the PCKey class. There
- needs to be only one instance and that is done for you
- automatically. The only instance of the PCKey class is
- "PC".
-
- Member functions of the PCKey class are available via the
- instance "PC":
-
-
- PC.enhanced() returns true if an extended keyboard is
- detected.
-
- PC.getch() Returns the ascii code of the character
- read. Automatically calls extended BIOS
- service for enhanced keyboards.
-
- PC.ascii() returns the ascii code of the last character
- read by PC.getch() or PC.kbhit().
-
- PC.scan() returns the scan code of the last character
- read by PC.getch() or PC.kbhit().
-
- PC.shift() returns the keyboard status flags.
- Automatically calls extended BIOS service
- for enhanced keyboards.
-
-
- The following boolean functions should be self explanatory.
-
-
- PC.InsertStateActive()
- PC.CapsLockActive()
- PC.NumLockActive()
- PC.ScrollLockActive()
- PC.AltPressed()
- PC.CtrlPressed()
- PC.LeftShiftPressed()
- PC.RightShiftPressed()
- PC.ShiftPressed()
-
- ( The next group is automatically enabled
- for enhanced keyboards )
-
- PC.SysReqPressed()
- PC.CapsLockPressed()
- PC.NumLockPressed()
- PC.ScrollLockPressed()
- PC.RightAltPressed()
- PC.RightCtrlPressed()
- PC.LeftAltPressed()
- PC.LeftCtrlPressed()
-
-
- PC.setTypeMatic() sets typematic rate/delay.
-
- PC.putch() writes asciiScanCode pair to keyboard
- buffer.
-
- PC.flush() flushes the keyboard buffer.
-
-
-
- The following code fragment demonstrates using the defined
- keys in pckey.hpp:
-
-
- switch (PC.getch()) {
- case 0: switch(PC.scan()) {
- case F1:
- ...
- break;
- case AltM:
- ...
- break;
- case Home:
- ...
- break;
- case CtrlLArr:
- ...
- break;
-
- }
- break;
- case ESC:
- ...
- break;
- case CR:
- ...
- break;
- default:
- ch = PC.ascii();
- ...
- break;
- }
-
-
- I think you get the idea. Just lookup the key you want
- in pckey.hpp. If it's a special key then PC.getch()
- returns zero and you read the scan code from PC.scan().
- Be sure to read the comments for ExtendKey at the end
- of pckey.hpp.
-
-
- I hope that you find pckey useful!
- Please be sure to send me your comments,
- I'll answer as many as I can (time, postage and/or
- billing charges permitting). John
-