home *** CD-ROM | disk | FTP | other *** search
- ..pgno01
- ..foot60A3-##
- ..head02L──────────────────────────────────────────────────────────────────────
- ..head04L──────────────────────────────────────────────────────────────────────
- ..head03ABiosKbdClr
- ■ Description
-
- Clear the keyboard buffer.
-
-
- ■ Summary
-
- Procedure BiosKbdClr;
-
-
- ■ Remarks
-
- BiosKbdClr uses the BIOS to clear any characters in the keyboard
- buffer waiting to be read.
-
-
- ■ See Also
-
- DosKbdClr
-
-
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Var
- Ch : Integer;
- Begin
- BiosKbdClr;
- Ch := GetKey;
- End.
-
- In this example the keyboard buffer is flushed before reading a
- keystroke from the keyboard.
- ..page
- ..head03ABiosKbdGetElmt
- ■ Description
-
- Returns an integer value for the key pressed on the keyboard.
-
-
- ■ Summary
-
- Function BiosKbdGetElmt : Integer;
-
-
- ■ Remarks
-
- BiosKbdGetElmt will return an integer in the range of 0-388. Use
- Appendix C as a guide to find the keyboard element code this
- function returns for a particular key pressed on the keyboard.
- When using DOS function calls there is not any method available to
- distinguish the difference between some keystokes and key
- combinations. An example of this is the Enter key and the Ctrl-M
- keys, both return a value of 145. Key combinations using the control
- key with an alpha character and all other ascii characters will be
- offset by 132.
-
-
- ■ See Also
-
- BiosKbdRead, DosKbdGetElmt, DosKbdRead
-
-
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Begin
- Writeln( 'Value of keypressed = ', BiosKbdGetElmt:1 );
- End.
-
- If Control-Break were pressed then zero would be displayed. If the
- 'A' were pressed then 197 would be displayed: (197 - 132 = 65).
- ..page
- ..head03ABiosKbdHit
- ■ Description
-
- Reports if a keystroke is waiting to be read from the keyboard
- buffer.
-
-
- ■ Summary
-
- Function BiosKbdHit : Boolean;
-
-
- ■ Remarks
-
- Using the BIOS services BiosKbdHit checks the keyboard status to
- determine if a key is waiting to be read from the keyboard buffer.
-
-
- ■ See Also
-
- DosKbdHit
-
-
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Begin
- While ( Not BiosKbdHit ) Do
- Writeln( 'Keyboard buffer empty...' );
- End.
-
- This program will display the keyboard buffer empty phrase on a new
- line until a key is pressed on the keyboard.
- ..page
- ..head03ABiosKbdRead
- ■ Description
-
- Read a character from the keyboard.
-
-
- ■ Summary
-
- Procedure BiosKbdRead( Ch : String );
-
- Ch returns a string of length zero, one, or two bytes long
- defining the key or key combination pressed from the
- keyboard.
-
-
- ■ Remarks
-
- BiosKbdRead reads a single character from the keyboard buffer.
- BiosKbdRead will return a zero, one, or two character string. A
- null string indicates that Ctrl- Break was pressed. A one-character
- string indicates a normal ascii character was read from the
- keyboard. A two-character string indicates a special extended
- keyboard code. Refer to appendix B for a list of the extended
- keyboard codes. The data type definition for BiosKbdRead is an
- untyped variable using a minimum of three bytes.
-
-
- ■ See Also
-
- BiosKbdGetElmt, DosKbdGetElmt, DosKbdRead
- ..page
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Var
- Ch : String;
- Begin
- BiosKbdRead( Ch );
- Case Ord( Ch[0] ) Of
- 0 : Writeln( 'Ctrl char pressed' );
- 27 : Writeln( 'Other key comb used' );
- 32..127 : Writeln( 'ASCII pressed' );
- End;
- End.
-
- In this example any key or key combination that is read from the
- keyboard will be grouped into one of three categories.
-
- If Ch[1] is equal to the null byte and the length byte is equal to
- two, then one of the control characters (0-31) was pressed. This
- includes the enter key, backspace, tab, and key combinations that
- use the control and an ACSII character A-Z. If Ch[1] is equal to
- #27 then some other key combination was used, generally involving
- the alt key or control key with one of the function keys or cursor
- movement keys. The string length will be two. If Ch[1] is in the
- range #32..#127 then an ASCII character was pressed. The length
- will also be one, where as in the other two possibilites the length
- will be two.
- ..page
- ..head03ABiosKbdStat
- ■ Description
-
- Get the keyboard status byte
-
-
- ■ Summary
-
- Function BiosKbdStat : Integer;
-
-
- ■ Remarks
-
-
- BiosKbdStat returns the keyboard status byte as follows:
-
- BITS
- ─────────────────────────────────
- | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
- ─────────────────────────────────
-
- Bit Bit Value Key Pressed
- --- --------- ──────────-
- 0 1 Right Shift
- 1 2 Left Shift
- 2 4 Control
- 3 8 Alternate
-
- Key Mode
- ───────────
- 4 16 Scroll Lock
- 5 32 Num Lock
- 6 64 Caps Lock
- 7 128 Insert
-
- A one in the bit position means the condition is true and a zero in
- the bit position means the condition is false.
- ..page
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Var
- i : Integer;
- Done : Boolean;
- Begin
- i := 0;
- Done := False;
-
- While ( Not Done ) Do Begin
- i := BiosKbdStat;
- If ( BiosKbdHit ) Then Begin
-
- If ( i And 2 ) <> 0 Then
- Done := True;
-
- ClrWin( 1, 1, 80, 25, 7 );
-
- If ( i And 16 ) <> 0 Then Writeln( 'Scroll Lock ON ' );
- Else Writeln( 'Scroll Lock OFF' );
-
- If ( i And 32 ) <> 0 Then Writeln( 'Num Lock ON ' );
- Else Writeln( 'Num Lock OFF' );
-
- If ( i And 64 ) <> 0 Then Writeln( 'Caps Lock ON ' );
- Else Writeln( 'Caps Lock OFF' );
-
- If ( i And 128 ) <> 0 Then Writeln( 'Insert ON ' );
- Else Writeln( 'Insert OFF' );
- End;
- End;
- End.
-
- In this example everytime a key is pressed the screen is cleared and
- the status for the Scroll Lock, Insert, Caps Lock and Num Lock keys
- is displayed in the upper left corner. This routine will not
- terminate until a key is pressed with the left shift key held down.
- ..page
- ..head03ADosKbdClr
- ■ Description
-
- Clear the keyboard buffer.
-
-
- ■ Summary
-
- Procedure DosKbdClr;
-
-
- ■ Remarks
-
- DosKbdClr uses DOS to clear any characters in the keyboard buffer
- waiting to be read.
-
-
- ■ See Also
-
- BiosKbdClr
-
-
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Var
- Ch : Integer;
- Begin
- DosKbdClr;
- Ch := GetKey;
- End.
-
- In this example the keyboard buffer is flushed before reading a
- keystroke from the keyboard.
- ..page
- ..head03ADosKbdGetElmt
- ■ Description
-
- Returns an integer value for the key pressed on the keyboard.
-
-
- ■ Summary
-
- Function DosKbdGetElmt : Integer;
-
-
- ■ Remarks
-
- DosKbdGetElmt will return an integer in the range of 0-388. Use
- Appendix C to find the keyboard element code this function returns
- for a particular key pressed on the keyboard.
-
- Key combinations using the control key with an alpha character and
- all other ascii characters will be offset by 132.
-
-
- ■ See Also
-
- BiosKbdGetElmt, BiosKbdRead, DosKbdRead
-
-
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Begin
- Writeln( 'Value of keypressed = ', DosKbdGetElmt:1 );
- End.
-
- If Control-Break were pressed then zero would be displayed. If the
- 'A' were pressed then 197 would be displayed: (197 - 132 = 65).
- ..page
- ..head03ADosKbdHit
- ■ Description
-
- Reports if a keystroke is waiting to be read from the keyboard
- buffer.
-
-
- ■ Summary
-
- Function DosKbdHit : Boolean;
-
-
- ■ Remarks
-
- Using the DOS services DosKbdHit checks the keyboard status to
- determine if a key is waiting to be read from the keyboard buffer.
-
-
- ■ See Also
-
- BiosKbdHit
-
-
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Begin
- While ( Not DosKbdHit ) Do
- Writeln( 'Keyboard buffer empty...' );
- End.
-
- This program will display the keyboard buffer empty phrase on a new
- line until a key is pressed on the keyboard.
- ..page
- ..head03ADosKbdRead
- ■ Description
-
- Read a character from the keyboard.
-
-
- ■ Summary
-
- Procedure DosKbdRead( CHAR PTR Ch );
-
- Ch returns a string of length zero, one, or two bytes long
- defining the key or key combination pressed from the
- keyboard.
-
-
- ■ Remarks
-
- DosKbdRead reads a single character from the keyboard buffer.
- DosKbdRead will return a zero, one, or two character string. A null
- string indicates that Ctrl- Break was pressed. A one-character
- string indicates a normal ascii character was read from the
- keyboard. A two-character string indicates a special extended
- keyboard code. Refer to appendix B for a list of the extended
- keyboard codes. The data type definition for DosKbdRead is an
- untyped variable using a minimum of three bytes.
-
-
- ■ See Also
-
- BiosKbdGetElmt, BiosKbdRead, DosKbdGetElmt
- ..page
- ■ Example
-
- Program Example;
- Uses FPKbd;
- Var
- Ch : String;
- Begin
- DosKbdRead;
- Case Ord( Ch[0] ) Of
- 0 : Writeln( 'Ctrl char pressed' );
- 27 : Writeln( 'Other key comb used' );
- 32..127 : Writeln( 'ASCII pressed' );
- End.
- End.
-
- In this example any key or key combination that is read from the
- keyboard will be grouped into one of three categories.
-
- If Ch[1] is equal to the null byte and the length byte is equal to
- two, then one of the control characters (0-31) was pressed. This
- includes the enter key, backspace, tab, and key combinations that
- use the control and an ACSII character A-Z. If Ch[1] is equal to
- #27 then some other key combination was used, generally involving
- the alt key or control key with one of the function keys or cursor
- movement keys. The string length will be two. If Ch[1] is in the
- range #32..#127 then an ASCII character was pressed. The length
- will also be one, where as in the other two possibilites the length
- will be two.
- ..page
- ..head03AGetKey
- ■ Description
-
- Returns a keystroke and map it into a keyboard element number for
- EditSt.
-
-
- ■ Summary
-
- Function GetKey : Integer;
-
-
- ■ Remarks
-
- This function may call other functions and procedures if it so
- desires. The only restriction is that it must return an integer
- value that is in the table found in Appendix C if the function
- EditSt is used. If EditSt is not used the only restriction is that
- an integer must be returned.
-
-
- ■ Example
-
- Program Example;
- Uses FPVideo,FPKbd;
-
- Function GetKey : Integer;
- Var
- i : Integer;
- Begin
- While ( Not DosKbdHit ) Do Begin
- FillRowChar( 1, 25, 80, ' ' );
-
- i := BiosKbdStat;
-
- If ( i And 16 ) <> 0 Then ColorMsg( 1, 25, 7, 'Scroll');
- If ( i And 32 ) <> 0 Then ColorMsg( 8, 25, 7, 'Num' );
- If ( i And 64 ) <> 0 Then ColorMsg( 12, 25, 7, 'Caps' );
- If ( i And 128 ) <> 0 Then ColorMsg( 17, 25, 7, 'Insert');
- End.
- GetKey := BiosKbdGetElmt;
- End;
-
- Begin
- Writeln( 'Key element number = ', GetKey:1 );
- End.
-
- This example polls the keyboard, gets the keyboard status byte and
- displays the status for four keys while a key has not been pressed.
- Once a key has been pressed on the keyboard the BiosKbdGetElmt
- function is called to get the keyboard element number.
- ..page
-