Go to the first, previous, next, last section, table of contents.


_bios_keybrd

Syntax

#include <bios.h>

unsigned _bios_keybrd(unsigned cmd);

Description

The _bios_keybrd routine uses INT 0x16 to access the keyboard services. The cmd argument can be any of the following manifest constants:

_KEYBRD_READ
Read the next key pressed
_NKEYBRD_READ
Read the next extended key pressed
_KEYBRD_READY
Check if the next key in the keyboard buffer
_NKEYBRD_READY
Check if the next extended key in the keyboard buffer
_KEYBRD_SHIFTSTATUS
Read keyboard shift state (0x0040:0x0017 byte):
7654 3210  Meaning
---- ---X  Right SHIFT is pressed
---- --X-  Left SHIFT is pressed
---- -X--  CTRL is pressed
---- X---  ALT is pressed
---X ----  Scroll Lock locked
--X- ----  Num Lock locked
-X-- ----  Caps Lock locked
X--- ----  Insert locked
_NKEYBRD_SHIFTSTATUS
Read keyboard shift and extended shift state (0x0040:0x0017 word):
FEDC BA98  7654 3210  Meaning
---- ----  ---- ---X  Right SHIFT is pressed
---- ----  ---- --X-  Left SHIFT is pressed
---- ----  ---- -X--  CTRL is pressed
---- ----  ---- X---  ALT is pressed
---- ----  ---X ----  Scroll Lock locked
---- ----  --X- ----  Num Lock locked
---- ----  -X-- ----  Caps Lock locked
---- ----  X--- ----  Insert locked

---- ---X  ---- ----  Left CTRL is pressed
---- --X-  ---- ----  Left ALT is pressed
---- -X--  ---- ----  Right CTRL is pressed
---- X---  ---- ----  Right ALT is pressed
---X ----  ---- ----  Scroll Lock is pressed
--X- ----  ---- ----  Num Lock is pressed
-X-- ----  ---- ----  Caps Lock is pressed
X--- ----  ---- ----  SysReq is pressed

Return Value

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 (that is, the same value as _KEYBRD_READ).

With the ???_READ and ???_READY arguments, the _bios_keybrd function returns -1 if CTRL+BREAK has been pressed and is the next keystroke to be read.

Portability

not ANSI, not POSIX

Example

while( !_bios_keybrd(_KEYBRD_READY) )
  try_to_do_something();


Go to the first, previous, next, last section, table of contents.