Borland C++ reference

bioskey

raw OCR

Keyboard interface, using BIOS services directly.

Defined in header <bios.h>

Syntax

#include <bios.h>
int bioskey(int cmd);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

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

Return value

The value returned by bioskey depends on the task it performs, determined by the value of cmd:

0If the lower 8 bits are nonzero, bioskey 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.
1This tests whether a keystroke is available to be read. A return value of zero means no key is available. The return value is 0xFFFFF (-1) if Ctrt-Brk has been pressed. Otherwise, the value of the next keystroke is returned. The keystroke itself is kept to be returned by the next call to bioskey that has a cmd value of zero.
2Requests the current shift key status. The value is obtained by ORing the following values together:
Bit 70x80Insert on
Bit 60x40Caps on
Bits0x20Num Lock on
Bit 40x10Scroll Lock on
Bits0x08Alt pressed
Bit 20x04Ctrl pressed
Bitl0x02<r- Shift pressed
BitO0x01-^ Shift pressed

Example

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

ttdefine RIGHT 0x01,
#define LEFT   0x02
#define CTRL   0x04
ttdefine ALT   0x08

int main(void)
{
   int key, modifiers;

   /* function 1 returns 0 until  a key is pressed */
   while (bioskey(l) == 0);

   /* function 0 returns the key  that is waiting */
   key = bioskey (0);

   /* use function 2 to determine  if shift keys are used */
   modifiers = bioskey (2);
   if (modifiers)  {
      printf(" [");
      if (modifiers & RIGHT) printf ("RIGHT");
      if (modifiers & LEFT)  printf ("LEFT");
      if (modifiers & CTRL)  printf ("CTRL");
      if (modifiers & ALT)   printf ("ALT");
      printf("]"),•
   }
   /* print out the character  read */
   if (isalnum(key & 0xFF))
      printf("'%c'\n" , key);
   else
      printf("%t02x\n", key);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.