Calls BIOS keyboard services, using INT 0x16.
#include <bios.h>
unsigned _bios_keybrd( unsigned service );
service | Keyboard function desired |
The _bios_keybrd routine uses INT 0x16 to access the keyboard services. The service argument can be any of the following manifest constants:
Constant | Meaning |
_KEYBRD_READ, _NKEYBRD_READ | Reads the next character from the keyboard. If no character has been typed, the call will wait for one. If the low-order byte of the return value is nonzero, the call contains the ASCII value of the character typed. The high-order byte contains the keyboard scan code for the character. The _NKEYBRD_READ constant is used with enhanced keyboards to obtain the scan codes for function keys F11 and F12 and the cursor control keys. | ||
_KEYBRD_READY, _NKEYBRD_READY | Checks whether a keystroke is waiting to be read and, if so, reads it. The return value is 0 if no keystroke is waiting, or it is the character waiting to be read, in the same format as the _KEYBRD_READ or _NKEYBRD_READ return. This service does not remove the waiting character from the input buffer, as does the _KEYBRD_READ or _NKEYBRD_READ service. The _NKEYBRD_READY constant is used with enhanced keyboards to obtain the scan codes for function keys F11 and F12 and the cursor control keys. | ||
_KEYBRD_SHIFTSTATUS, _NKEYBRD_SHIFTSTATUS | Returns the current SHIFT-key status. _KEYBRD_SHIFTSTATUS returns only low byte. The _NKEYBRD_SHIFTSTATUS constant is used to get a full 16-bit status value. Any combination of the following bits may be set: | ||
Bit | Meaning if True | ||
00H | Rightmost SHIFT key pressed | ||
01H | Leftmost SHIFT key pressed | ||
02H | Either CTRL key pressed | ||
3H | Either ALT key pressed | ||
04H | SCROLL LOCK on | ||
05H | NUM LOCK on | ||
06H | CAPS LOCK on | ||
07H | In insert mode (INS) | ||
08H | Left CTRL key pressed | ||
09H | Left ALT key pressed | ||
0AH | Right CTRL key pressed | ||
0BH | Right ALT key pressed | ||
0CH | SCROLL LOCK key pressed | ||
0DH | NUM LOCK key pressed | ||
0EH | CAPS LOCK key pressed | ||
0FH | SYS REQ key pressed |
With the ...READ and ...SHIFTSTATUS arguments, the _bios_keybrd function returns the contents of the AX register after the BIOS call.
With the ...READY argument, _bios_keybrd returns 0 if there is no key. If there is a key, _bios_keybrd returns the key waiting to be read (i.e., the same value as _KEYBRD_READ).
With the ...READ and the ...READY arguments, the _bios_keybrd function returns –1 if CTRL+BREAK has been pressed and is the next keystroke to be read.
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
/* BKEYBRD.C: This program prints a message on the screen until the
* right SHIFT key is pressed.
*/
#include <bios.h>
#include <stdio.h>
void main( void )
{
while( !(_bios_keybrd( _KEYBRD_SHIFTSTATUS ) & 0001) )
printf( "Use the right SHIFT key to stop this message\n" );
printf( "Right SHIFT key pressed\n" );
}
Use the right SHIFT key to stop this message
Use the right SHIFT key to stop this message
Use the right SHIFT key to stop this message
Use the right SHIFT key to stop this message
Right SHIFT key pressed