GR_EVENT_KEYSTROKE

Name

GR_EVENT_KEYSTROKE -- Keyboard event structure

Synopsis

typedef struct 
{
    GR_EVENT_TYPE   type;
    GR_WINDOW_ID    wid;
    GR_WINDOW_ID    subwid;
    GR_COORD        rootx;
    GR_COORD        rooty;
    GR_COORD        x;
    GR_COORD        y;
    int             buttons;
    int             modifiers;
    GR_UNICODE      uch;
    unsigned int    special;
    GR_CHAR         ch;
    unsigned char   content;
} GR_EVENT_KEYSTROKE;
  

Description

The GR_EVENT_KEYSTROKE structure is used by nano-X to pass the application keyboard events.

The keystroke will be sent to the highest window that contains the mouse cursor and has selected to receive keystroke events, if that window is a decendant of the focus window. Otherwise the keystroke is sent to the focus window or it's highest ancestor that has selected to receive keystroke events.

Fields

TypeNameDescription
GR_EVENT_TYPEtypeThe event type will be either a GR_EVENT_TYPE_KEY_DOWN or a GR_EVENT_TYPE_KEY_UP type.
GR_WINDOW_IDwidThe ID of the window that the keystroke event is being sent to.
GR_WINDOW_IDsubwidThe ID of the window that the mouse is in. Generally this field will be the same as wid, but in some cases if the mouse event occurs in a decendant of wid, then this field indicates that child window.
GR_COORDrootxThe X coordinate of the mouse pointer relative to the root window.
GR_COORDrootyThe Y coordinate of the mouse pointer relative to the root window.
GR_COORDxThe X coordinate of the mouse pointer relative to the window wid.
GR_COORDyThe Y coordinate of the mouse pointer relative to the window wid.
intbuttonsIndicates the mouse buttons that are being pressed. This field will be 0 if all buttons are released or a bitwise OR of GR_BUTTON_R, GR_BUTTON_M and/or GR_BUTTON_L if one or more buttons are pressed.
intmodifiersIndicates the status of the keyboard modifier keys. This field will be 0 if no modifiers are pressed, or a bitwise OR of one or more of GR_MODIFIER_CTRL, GR_MODIFIER_META, GR_MODIFIER_SHIFT, GR_MODIFIER_LOCK, GR_MODIFIER_NUMLOCK and/or GR_MODIFIER_SCROLLLOCK if one or more modifier keys is pressed.
GR_UNICODEuchThe key that caused the keystroke event.
unsigned intspecialSpecial key sequences (see below).
GR_CHARchThe key that caused the keystroke event.
unsigned charcontentKeystroke content flags (see below).

Special Flags & Content

These actions have not yet been implemented as of Nano-X revision 0.89pre6.

The goal is to tag each keystroke event with a set of content flags. These content flags will indicate what type of data is actually contained in the keystroke event structure. The following two tables shown typical key sequences. The first table shows just the A key being pressed. The following table shows the key sequence F10 A being pressed.

chuchspecialcontent
A0x00410GR_KEYSTROKE_CONTENT_8BIT_PROPER GR_KEYSTROKE_CONTENT_UNICODE_PROPER

chuchspecialcontent
Esc0x001B0GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ
[0x005B0GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ
20x00320GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ
10x00310GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ
~0x007EGR_SPECIAL_KEY_F10GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQ GR_KEYSTROKE_CONTENT_SPECIAL
A0x00410GR_KEYSTROKE_CONTENT_8BIT_PROPER GR_KEYSTROKE_CONTENT_UNICODE_PROPER

If your application only supports 8 bit characters, you should ignore all keystrokes that do not have the GR_KEYSTROKE_CONTENT_8BIT_PROPER, GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQ or GR_KEYSTROKE_CONTENT_SPECIAL flags set. The GR_EVENT_KEYSTROKE structure always has an 8 bit key code field. But in some environments if a unicode character that does not have an 8 bit equivalent is contained in the keystroke event, the ch field will contain garbage.

Content Flag NameDescription
GR_KEYSTROKE_CONTENT_8BIT_PROPERThe ch field contains an ASCII key code.
GR_KEYSTROKE_CONTENT_8BIT_CTRLSEQThe ch field contains an ASCII control sequence.
GR_KEYSTROKE_CONTENT_UNICODE_PROPERThe uch field contains a unicode key code.
GR_KEYSTROKE_CONTENT_UNICODE_CTRLSEQThe uch field contains a unicode control sequence.
GR_KEYSTROKE_CONTENT_SPECIALThe special field contains a special key (see below).

Special Key NameDescription
GR_SPECIAL_KEY_NOSPECIALNo special key preceeded this key.
GR_SPECIAL_KEY_F1The F1 key.
GR_SPECIAL_KEY_F2The F2 key.
GR_SPECIAL_KEY_F3The F3 key.
GR_SPECIAL_KEY_F4The F4 key.
GR_SPECIAL_KEY_F5The F5 key.
GR_SPECIAL_KEY_F6The F6 key.
GR_SPECIAL_KEY_F7The F7 key.
GR_SPECIAL_KEY_F8The F8 key.
GR_SPECIAL_KEY_F9The F9 key.
GR_SPECIAL_KEY_F10The F10 key.
GR_SPECIAL_KEY_F11The F11 key.
GR_SPECIAL_KEY_F12The F12 key.
GR_SPECIAL_KEY_NUM0The 0 key on the number pad.
GR_SPECIAL_KEY_NUM1The 1 key on the number pad.
GR_SPECIAL_KEY_NUM2The 2 key on the number pad.
GR_SPECIAL_KEY_NUM3The 3 key on the number pad.
GR_SPECIAL_KEY_NUM4The 4 key on the number pad.
GR_SPECIAL_KEY_NUM5The 5 key on the number pad.
GR_SPECIAL_KEY_NUM6The 6 key on the number pad.
GR_SPECIAL_KEY_NUM7The 7 key on the number pad.
GR_SPECIAL_KEY_NUM8The 8 key on the number pad.
GR_SPECIAL_KEY_NUM9The 9 key on the number pad.
GR_SPECIAL_KEY_NUM_PERIODThe . key on the number pad.
GR_SPECIAL_KEY_NUM_ENTERThe Enter key on the number pad.
GR_SPECIAL_KEY_NUM_PLUSSThe + key on the number pad.
GR_SPECIAL_KEY_NUM_MINUSThe - key on the number pad.
GR_SPECIAL_KEY_NUM_STARThe * key on the number pad.
GR_SPECIAL_KEY_NUM_SLASHThe / key on the number pad.
GR_SPECIAL_KEY_ESCThe Esc key.
GR_SPECIAL_KEY_TABThe Tab key.
GR_SPECIAL_KEY_INSERTThe Insert key.
GR_SPECIAL_KEY_DELETEThe Delete key.
GR_SPECIAL_KEY_BACKSPACEThe BackSpace key.
GR_SPECIAL_KEY_PAGEUPThe PageUp key.
GR_SPECIAL_KEY_PAGEDOWNThe PageDown key.
GR_SPECIAL_KEY_HOMEThe Home key.
GR_SPECIAL_KEY_ENDThe End key.
GR_SPECIAL_KEY_ARROW_LEFTThe left arrow key.
GR_SPECIAL_KEY_ARROW_RIGHTThe right arrow key.
GR_SPECIAL_KEY_ARROW_UPThe up arrow key.
GR_SPECIAL_KEY_ARROW_DOWNThe down arrow key.

See Also

GR_EVENT, GR_EVENT_MOUSE.