Event in pygame are handled through the pygame.event module. The pygame.event.get() method gets all the events from the event queue. The event queue is a list of event objects that are sent to the program by the window manager or by the pygame program itself. The pygame.event.get() method returns a list of pygame.event.Event objects. Each Event object has an event type stored in the type attribute. The type attribute can be compared to the constants defined in the pygame.locals module. The pygame.locals module defines constants for the event types. The event types are used to determine what type of event has occurred. The event types are listed below:
KEYDOWN is an event type that is fired when a key is pressed down. like when you press a key on the keyboard.
KEYUP is an event type that is fired when a key is released. like when you lift your finger off a key.
MOUSEMOTION is an event type that is fired when the mouse is moved.
MOUSEBUTTONDOWN is an event type that is fired when a mouse button is pressed down.
MOUSEBUTTONUP is an event type that is fired when a mouse button is released.