Checking the Status of Key Modifiers (PCDOS and OS/2)

In the PCDOS and OS/2 environments, you can determine whether any of the key modifiers are currently being pressed down or one of the key modifier toggles are locked into the "on" position. The key modifiers that can be tested are as follows:

    Insert/overwrite mode

    Caps Lock

    Num Lock

    Scroll Lock

    Alt key

    Ctrl key

    Left Shift key

    Right Shift key

If using an extended keyboard, more checks are allowed.

To check the status of the different key modifiers, use the keyboard input status function, ki_stat():

int ki_stat()

This function returns an integer with bits set for each key modifier that is being held down at the moment. Each key modifier is assigned a bit mask so that you can test which key modifiers are currently pressed. The #defined names for each bit mask and what they indicate are shown in Table 41.1.

Table 41.1: Keyboard Status Bit Masks (PCDOS and OS/2)

#define If bit value is on, then
INSMODE_ON Insert mode is toggled on
CAPS_LOCK Caps Lock is toggled on
NUM_LOCK Num Lock is toggled on
SCRL_LOCK Scroll lock is toggled on
ALT_ISDOWN The Alt key is down
CTRL_ISDOWN The Ctrl key is down
LSHIFT_ISDOWN The left shift key is down
RSHIFT_ISDOWN The right shift key is down
The following are for extended BIOS versions or extended keyboards only:
LCTRL_ISDOWN The left Ctrl key is down
LALT_ISDOWN The left Alt key is down
RCTRL_ISDOWN The right Ctrl key is down
RALT_ISDOWN The right Alt key is down
SCRL_ISDOWN Scroll Lock is down
NUM_ISDOWN Num Lock is down
CAPS_ISDOWN Caps Lock is down
SYS_ISDOWN SYS_REQ key is down


Home Contents Previous Next