building games with pygame using joystick can generate several different types of event including joyaxismotionjoyballmotionjoybuttondown and joybu ttonup these event types tell you what occurred to generate the event this means that you can choose which types of events you want to deal with and ignore other events event information each type of event object provides information associated with that event for example key oriented event object will provide the actual key pressed while mouse oriented event object will provide information on the position of the mousewhich button was pressed etc if you try an access an attribute on an event that does not support that attributethen an error will be generated the following lists some of the attributes available for different event typeskeydown and keyupthe event has key attribute and mod attribute (indicating if any other modifying keys such as shift are also being pressedmousebuttonup and mousebuttondown has an attribute pos that holds tuple indicating the mouse location in terms of and coordinates on the underlying surface it also has button attribute indicating which mouse was pressed mousemotion has posrel and buttons attributes the pos is tuple indicating the and location of mouse cursor the real attribute indicates the amount of mouse movement and buttons indicates the state of the mouse buttons as an example if we want to check for keyboard event type and then check that the key pressed was the space barthen we can writeif event type =pygame keydowncheck to see which key is pressed if event key =pygame k_spaceprint('space'this indicates that if it is key pressed event and that the actual key was the space barthen print the string 'spacethere are many keyboard constants that are used to represent the keys on the keyboard and pygame k_space constant used above is just one of them all the keyboard constants are prefixed with 'k_followed by the key or the name of the keyfor example