##### pygame-ce documentation

Pygame-ce Home || Help Contents || Reference Index

Most useful stuff: Color | display | draw | event | font | image | key | locals | mixer | mouse | Rect | Surface | time | music | pygame

Advanced stuff: cursors | joystick | mask | sprite | transform | BufferProxy | freetype | gfxdraw | midi | PixelArray | pixelcopy | sndarray | surfarray | math

Other: camera | controller | examples | scrap | system | tests | touch | typing | version | Window

## src_c/event.c

The extension module `pygame.event` pygame module for interacting with events and queues.

Header file: src_c/include/pygame.h

type pgEventObject

  The `pygame.event.EventType` object C struct.

  int type

    The event type code.

type pgEvent_Type

  The pygame event object type `pygame.event.EventType`.

int pgEvent_Check(PyObject *x)

  Return true if x is a pygame event instance

  Will return false if x is a subclass of event. This is a macro. No check is made that x is not `NULL`.

PyObject *pgEvent_New(SDL_Event *event)

  Return a new pygame event instance for the SDL event. If event is `NULL` then create an empty event object. On failure raise a Python exception and return `NULL`.

char *pgEvent_GetKeyDownInfo(void)

  Return an array of bools (using char) of length SDL_NUM_SCANCODES with the most recent key presses.

char *pgEvent_GetKeyUpInfo(void)

  Return an array of bools (using char) of length SDL_NUM_SCANCODES with the most recent key releases.

char *pgEvent_GetMouseButtonDownInfo(void)

  Return an array of bools (using char) of length 5 with the most recent button presses.

char *pgEvent_GetMouseButtonUpInfo(void)

  Return an array of bools (using char) of length 5 with the most recent button releases.

int pg_post_event(Uint32 type, PyObject *dict)

  Posts a pygame event that is an `SDL_USEREVENT` on the SDL side. This function takes a python dict, which can be NULL too. This function does not need GIL to be held if dict is NULL, but needs GIL otherwise. Just like the SDL `SDL_PushEvent` function, returns 1 on success, 0 if the event was not posted due to it being blocked, and -1 on failure.

int pg_post_event_dictproxy(Uint32 type, pgEventDictProxy *dict_proxy)

  Posts a pygame event that is an `SDL_USEREVENT` on the SDL side, can also optionally take a dictproxy instance. Using this dictproxy API is especially useful when multiple events that need to be posted share the same dict attribute, like in the case of event timers. This way, the number of python increfs and decrefs are reduced, and callers of this function don't need to hold GIL for every event posted, the GIL only needs to be held during the creation of the dictproxy instance, and when it is freed. Just like the SDL `SDL_PushEvent` function, returns 1 on success, 0 if the event was not posted due to it being blocked, and -1 on failure.

Edit on GitHub