Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <bios.h>
    unsigned short _bios_keybrd( unsigned service );

Description:
    The _bios_keybrd function uses INT 0x16 to access the BIOS keyboard
    services.  The possible values for service are the following constants:

    _KEYBRD_READ
        Reads the next character from the keyboard.  The function will wait
        until a character has been typed.

    _KEYBRD_READY
        Checks to see if a character has been typed.  If there is one, then
        its value will be returned, but it is not removed from the input
        buffer.

    _KEYBRD_SHIFTSTATUS
        Returns the current state of special keys.

    _NKEYBRD_READ
        Reads the next character from an enhanced keyboard.  The function
        will wait until a character has been typed.

    _NKEYBRD_READY
        Checks to see if a character has been typed on an enhanced keyboard.
         If there is one, then its value will be returned, but it is not
        removed from the input buffer.

    _NKEYBRD_SHIFTSTATUS
        Returns the current state of special keys on an enhanced keyboard.


Returns:
    The return value depends on the service requested.

    The _KEYBRD_READ and _NKEYBRD_READ services return the character's ASCII
    value in the low-order byte and the character's keyboard scan code in
    the high-order byte.

    The _KEYBRD_READY and _NKEYBRD_READY services return zero if there was
    no character available, otherwise it returns the same value returned by
    _KEYBRD_READ and _NKEYBRD_READ.

    The shift status is returned in the low-order byte with one bit for each
    special key defined as follows:

    bit 0 (0x01)
        Right SHIFT key is pressed

    bit 1 (0x02)
        Left SHIFT key is pressed

    bit 2 (0x04)
        CTRL key is pressed

    bit 3 (0x08)
        ALT key is pressed

    bit 4 (0x10)
        SCROLL LOCK is on

    bit 5 (0x20)
        NUM LOCK is on

    bit 6 (0x40)
        CAPS LOCK is on

    bit 7 (0x80)
        Insert mode is set


Example:
    #include <stdio.h>
    #include <bios.h>

    void main()
      {
        unsigned short key_state;

        key_state = _bios_keybrd( _KEYBRD_SHIFTSTATUS );
        if( key_state & 0x10 )
            printf( "SCROLL LOCK is on\n" );
        if( key_state & 0x20 )
            printf( "NUM LOCK is on\n" );
        if( key_state & 0x40 )
            printf( "CAPS LOCK is on\n" );
      }

    produces the following:

    NUM LOCK is on

Classification:
    BIOS

Systems:
    DOS, Win, NT, DOS/PM

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson