The KEYBOARD object

The t_keyboard structure is used for getting information from keyboard. This object is placed in t_driver object. Whenever the "OBJECT(driver)->translate_event..." is called it calls also "translate_event" function from the t_keyboard, t_mouse etc. structures.

The t_keyboard structure


     Name:         struct t_object obclass; 

     Description:  Inherits functions from t_object.

     Name:         l_int  code;

     Description:  Code of the key. When you want to know if key was pressed 
                   you use the objects "state" variable. For example:

                      if ( key->obclass.state & KB_SF_KEYDOWN )

                   or even better:

                      if ( OBJECT(key)->state & KB_SF_KEYDOWN )

                   To check for ALT+X you type:

                      if ( OBJECT(key)->state & KB_SF_KEYDOWN && 
                                       key->code == TO_ALT(KB_X))

                   To check for CTRL+F5 you type:

                      if ( OBJECT(key)->state & KB_SF_KEYDOWN && 
                                     key->code == TO_CTRL(KB_F5))

     Name:         l_int  shifts;

     Description:  Contains information about shifts that was pressed.
                   The following shifts are supported by Allegro:

                      #define KB_SHIFT_FLAG      0x0001
                      #define KB_CTRL_FLAG       0x0002
                      #define KB_ALT_FLAG        0x0004
                      #define KB_LWIN_FLAG       0x0008
                      #define KB_RWIN_FLAG       0x0010
                      #define KB_MENU_FLAG       0x0020
                      #define KB_SCROLOCK_FLAG   0x0100
                      #define KB_NUMLOCK_FLAG    0x0200
                      #define KB_CAPSLOCK_FLAG   0x0400
                      #define KB_INALTSEQ_FLAG   0x0800
                      #define KB_ACCENT1_FLAG    0x1000
                      #define KB_ACCENT1_S_FLAG  0x2000
                      #define KB_ACCENT2_FLAG    0x4000
                      #define KB_ACCENT2_S_FLAG  0x8000

     Name:         l_char  keychar;

     Description:  Contains char of the key.


simulate_keypress ()
       Simulates a key being pressed by the user.

       void  (*simulate_keypress) ( p_keyboard o, l_int keycode );

       o           The keyboard object.
       keycode     Key to be pressed.