DeskLib 2.90a:Kbd.h


Contents


Introduction and Overview

This defines routines for relatively low-level reading from the keyboard.


Functions


Kbd_KeyDown

BOOL Kbd_KeyDown(int keynum);

This checks to see if the given key is currently being pressed. 'keynum' is a negative INKEY number.

The only values you should ever have to use with this in the Desktop are defined by the kbd_neginkey enum.


Kbd_GET

char Kbd_GET(void );

This is an OS_ReadC veneer. It returns the ASCII code of the next key pressed (which may already be in the keyboard buffer). This is effectively a C version of BASIC's GET command, hence the name.


Kbd_GetModifiers

kbd_modifiers Kbd_GetModifiers(BOOL detailed);

This returns the current state of the modifier keys (Alt, Shift and Ctrl). If you set detailed to TRUE it checks and fills in the state of the left and right keys as well.


Types


kbd_neginkey

typedef enum
{
inkey_ADJUST = -12,
inkey_MENU = -11,
inkey_SELECT = -10,
inkey_RALT = -9,
inkey_LALT = -6,
inkey_ALT = -3,
inkey_RCTRL = -8,
inkey_LCTRL = -5,
inkey_CTRL = -2,
inkey_RSHIFT = -7,
inkey_LSHIFT = -4,
inkey_SHIFT = -1
} kbd_neginkey;

These are the only keys you should actually have to test for in the Desktop environment. All other keys you are interested in should come in via Wimp events.

The names are self-explanatory, with the first three corresponding to mouse buttons and the rest giving right-only, left-only or either left or right tests.

If you need other values, the negative inkey code corresponds to the -1-(internal key code). The key codes can be found in the PRMs or in the "OS" Stronghelp manual at the time of writing.


kbd_modifiers

typedef struct
{
unsigned alt : 1;
unsigned ctrl : 1;
unsigned shift : 1;
unsigned left_alt : 1;
unsigned left_ctrl : 1;
unsigned left_shift : 1;
unsigned right_alt : 1;
unsigned right_ctrl : 1;
unsigned right_shift : 1;

} kbd_modifiers;

For each modifier key, when the flag is TRUE it means that the key is held down.