X"B0" function 2

Tests the status of the Shift, Alt, Ctrl and Lock keys.
Note: This routine is supported for native COBOL only, and only on Windows platforms.

Syntax:

call X"B0" using function-code
                 status-block

Parameters:

function-code
Call prototype: cblt-x1-compx
Picture: pic x comp-x.
status-block
Group containing:
01  status-block
  03 status-inds  pic x           *> pic x 
  03 status-id    cblt-x1-compx   *> pic x comp-x. 
  03 status-res   pic x(6)        *> pic x(6)

On Entry:

function-code
Value 2.
status-id
Must be set to 2. It is overwritten by the call, so must be reset to 2 before each call.
status-res
Reserved.

On Exit:

status-inds
Contains bit settings indicating the status of the keys (1=key pressed, 0=key not pressed) in the following order:
bit 7 Ins
bit 6 Caps Lock
bit 5 Num Lock
bit 4 Scroll Lock
bit 3 Alt
bit 2 Ctrl
bit 1 Shift (left key only)
Restriction: Console applications cannot distinguish between the left and right Shift keys, and so bit 0 is always returned when either Shift key is pressed. (The restriction does not apply to GUI applications.)
bit 0 Shift (right key only)

Comments:

For the Alt, Ctrl and Shift keys, the routine returns a 1 only if the key is actually pressed when the routine is called; for the other keys, the relevant bit is alternately set and unset each time the key is pressed.

Effective use of function 2 requires that the call is repeated at very frequent intervals.