delorie.com/djgpp/doc/libc/libc_73.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

bioskey

Syntax

 
#include <bios.h>

int bioskey(int command)

Description

This function issues the BIOS keyboard interrupt 16h with command in the AH register, and returns the results of that call. The argument command can accept the following values:

command = 00h

Returns the next key pressed. The value returned is a combination of the key's scan code in the high 8 bits and its ASCII code in the low 8 bits. For non-alphanumeric keys, such as the arrow keys, the low 8 bits are zeroed.

command = 01h

Checks the keyboard, returns zero if no key pressed, else the key. Does not dequeue the key from the keyboard buffer. The value returned when a key was pressed is a combination of the key's scan code in the high 8 bits and either its ASCII code or zero in the low 8 bits.

If the Ctrl-BREAK key was pressed, returns -1.

command = 02h

Returns the keyboard shift state:

 
7654 3210  Meaning

---- ---X  Right shift key down
---- --X-  Left shift key down
---- -X--  Ctrl key down
---- X---  Alt key down
---X ----  Scroll lock on
--X- ----  Num lock on
-X-- ----  Caps lock on
X--- ----  Insert on

command = 10h

Returns the next extended key pressed. This works like the case of command = 0, but it recognizes additional keys from the AT-style extended 101-key keyboard, like the second Alt key and F12. If a key was pressed, returns the scan code and ASCII code packed in same way as for command = 0, except that the extended keys have the E0h prefix in the low 8 bits.

Almost every PC nowadays has an extended 101-key keyboard.

command = 11h

Like the case of command = 1, but recognizes the additional keys of the extended keyboard.

command = 12h

Returns the two status bytes of the enhanced keyboard, packed in the low 16 bits of the return value. The individual bits of the return value are defined in the following table:

 
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

Depends on command.

Portability

ANSI/ISO C No
POSIX No

Example

 
while (!bioskey(1))
  do_stuff();


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004