Borland C++ reference

_bios_keybrd

raw OCR

Keyboard interface, using BIOS services directly.

Defined in header <bios.h>

Syntax

#include <bios.h>
unsigned _bios_keybrd(unsigned  and);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

_bios_keybrd performs various keyboard operations using BIOS interrupt 0x16. The parameter cmd determines the exact operation.

Return value

The value returned by _blos_keybrd depends on the task it performs, determined by the value of cmd (defined in bios.h):

_KEYBRD_READ If the lower 8 bits are nonzero, _bios_keybrd returns the ASCII charac-ter for the next keystroke waiting in the queue or the next key pressed at the keyboard. If the lower 8 bits are zero, the upper 8 bits are the extended keyboard codes defined in the IBM PC Technical Reference Manual.

_NKEYBRD_READ

Use this value instead of _KEYBRD_READYto read the keyboard

codes for enhanced keyboards, which have additional cursor and function keys.

_KEYBRD_READY This tests whether a keystroke is available to be read. A return value of zero means no key is available. The return value is 0xFFFF (-1) if Ctrl-Brk has been pressed. Otherwise, the value of the next keystroke is

returned, as described in _KEYBRD_READ(above). The keystroke

itself is kept to be returned by the next call to _bios_keybrd that has a

cmd value of _KEYBRD_READor _NKEYBRD_READ.

_NKEYBRD_READY Use this value to check the status of enhanced keyboards, which have additional cursor and function keys.

_KEYBRD_SHIFrSTATUS Requests the current shift key status. The value will contain an OR of zero or more of the following values:

Bit 70x80Insert on
Bit 60x40Caps on
Bits0x20Num Lock on
Bit 40x10Scroll Lock on
Bits0x08Alt pressed
Bit 20x04expressed
Bitl0x02Left SM pressed
BitO0x01Right Shnt pressed

_NKEYBRD_SHIFTSTATUS

Use this value instead of _KEYBRD_SHIFTSTATUSto request the full

16-bit shift key status for enhanced keyboards. The return value will contain an OR of zero or more of the bits defined above in

_KEYBRD_SHIFrSTATUS, Bit 15 0x8000 Sys Req pressedand additionally, any of the following bits:
Bit 140x4000Caps Lock pressed
Bit 130x2000Num Lock pressed
Bit 120x1000Scro//Loc/c pressed
Bit 110x0800Right Alt pressed
Bit 100x0400Right Cm pressed
Bit 90x0200Left Alt pressed
Bit 80x0100Left CM pressed

Example

#include <stdio.h>
#include <bios.h>
iinclude <ctype.h>

ttdefine RIGHT 0x01
tdefine LEFT   0x02
tdefine CTRL   0x04
tdefine ALT    0x08

int main (void)
1
   int key, modifiers;

   /* Wait until a key is pressed  */
   while  (_bios_keybrd(_KEYBRD_READY) == 0);

   /* Fetch the key that  is waiting */
   key = _bios_keybrd(_KEYBRD_READ);

   /* Determine if shift keys  are used */
   modifiers = _bios_keybrd(_KEYBRD_SHIFTSTATUS)
   if (modifiers)!
      printf("["),•
      if  (modifiers & RIGHT) printf("RIGHT");
      if  (modifiers & LEFT) printf ("LEFT");
      if  (modifiers & CTRL) printf ("CTRL");
   if  (modifiers & ALT)   printf("ALT"
   printfC']");

/* print out the character  read */
if (isalnum(key & 0xFF))
   printf {"'%c'\n", key);
else
   printf {"%#02x\n", key);
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.