pygame documentation | || Home || Help Contents || || pygame || cdrom || constants || display || draw || event || || font || image || joystick || key || mixer || mixer_music || || mouse || movie || sndarray || surfarray || time || transform || || CD || Channel || Clock || Font || Joystick || Movie || || Rect || Sound || Surface || || cursors || sprite ||

## pygame.constants

These constants are defined by SDL, and needed in pygame. Note that many of the flags for SDL are not needed in pygame, and are not included here. These constants are generally accessed from the pygame.locals module. This module is automatically placed in the pygame namespace, but you will usually want to place them directly into your module's namespace with the following command, 'from pygame.locals import *'.

display | - The following constants are used by the display module and Surfaces
events | - These constants define the various event types
keyboard | - These constants represent the keys on the keyboard.
modifiers | - These constants represent the modifier keys on the keyboard.
zdepracated | - The following constants are made available, but generally not needed

display
`pygame.constants.display (constants)`

HWSURFACE - surface in hardware video memory. (equal to 1)
RESIZABLE - display window is resizeable
ASYNCBLIT - surface blits happen asynchronously (threaded)
OPENGL - display surface will be controlled by opengl
HWPALETTE - display surface has animatable hardware palette entries
DOUBLEBUF - hardware display surface is page flippable
FULLSCREEN - display surface is fullscreen (nonwindowed)
RLEACCEL - compile for quick alpha blits, only set in alpha or colorkey funcs
NOFRAME - no window decorations

events
`pygame.constants.events (constants)`

NOEVENT - no event, represents an empty event list, equal to 0
ACTIVEEVENT - window has gain/lost mouse/keyboard/visiblity focus
KEYDOWN - keyboard button has been pressed (or down and repeating)
KEYUP - keyboard button has been released
MOUSEMOTION - mouse has moved
MOUSEBUTTONDOWN- mouse button has been pressed
MOUSEBUTTONUP - mouse button has been released
JOYAXISMOTION - an opened joystick axis has changed
JOYBALLMOTION - an opened joystick ball has moved
JOYHATMOTION - an opened joystick hat has moved
JOYBUTTONDOWN - an opened joystick button has been pressed
JOYBUTTONUP - an opened joystick button has been released
VIDEORESIZE - the display window has been resized by the user
QUIT - the user has requested the game to quit
SYSWMEVENT - currently unsupported, system dependant
USEREVENT - all user messages are this or higher
NUMEVENTS - all user messages must be lower than this, equal to 32

keyboard
`pygame.constants.keyboard (constants)`

There are many keyboard constants, they are used to represent keys on the keyboard. The following is a list of all keyboard constants

KeyASCII | ASCII | Common Name
K_BACKSPACE | \b | backspace
K_TAB | \t | tab
K_CLEAR |  | clear
K_RETURN | \r | return
K_PAUSE |  | pause
K_ESCAPE | ^[ | escape
K_SPACE |  | space
K_EXCLAIM | ! | exclaim
K_QUOTEDBL | \" | quotedbl
K_HASH | # | hash
K_DOLLAR | $ | dollar
K_AMPERSAND | & | ampersand
K_QUOTE |  | quote
K_LEFTPAREN | ( | left parenthesis
K_RIGHTPAREN | ) | right parenthesis
K_ASTERISK | * | asterisk
K_PLUS | + | plus sign
K_COMMA | , | comma
K_MINUS | - | minus sign
K_PERIOD | . | period
K_SLASH | / | forward slash
K_0 | 0 | 0
K_1 | 1 | 1
K_2 | 2 | 2
K_3 | 3 | 3
K_4 | 4 | 4
K_5 | 5 | 5
K_6 | 6 | 6
K_7 | 7 | 7
K_8 | 8 | 8
K_9 | 9 | 9
K_COLON | : | colon
K_SEMICOLON | ; | semicolon
K_LESS | < | less-than sign
K_EQUALS | = | equals sign
K_GREATER | > | greater-than sign
K_QUESTION | ? | question mark
K_AT | @ | at
K_LEFTBRACKET | [ | left bracket
K_BACKSLASH | \\ | backslash
K_RIGHTBRACKET | ] | right bracket
K_CARET | ^ | caret
K_UNDERSCORE | _ | underscore
K_BACKQUOTE | ` | grave
K_a | a | a
K_b | b | b
K_c | c | c
K_d | d | d
K_e | e | e
K_f | f | f
K_g | g | g
K_h | h | h
K_i | i | i
K_j | j | j
K_k | k | k
K_l | l | l
K_m | m | m
K_n | n | n
K_o | o | o
K_p | p | p
K_q | q | q
K_r | r | r
K_s | s | s
K_t | t | t
K_u | u | u
K_v | v | v
K_w | w | w
K_x | x | x
K_y | y | y
K_z | z | z
K_DELETE |  | delete
K_KP0 |  | keypad 0
K_KP1 |  | keypad 1
K_KP2 |  | keypad 2
K_KP3 |  | keypad 3
K_KP4 |  | keypad 4
K_KP5 |  | keypad 5
K_KP6 |  | keypad 6
K_KP7 |  | keypad 7
K_KP8 |  | keypad 8
K_KP9 |  | keypad 9
K_KP_PERIOD | . | keypad period
K_KP_DIVIDE | / | keypad divide
K_KP_MULTIPLY | * | keypad multiply
K_KP_MINUS | - | keypad minus
K_KP_PLUS | + | keypad plus
K_KP_ENTER | \r | keypad enter
K_KP_EQUALS | = | keypad equals
K_UP |  | up arrow
K_DOWN |  | down arrow
K_RIGHT |  | right arrow
K_LEFT |  | left arrow
K_INSERT |  | insert
K_HOME |  | home
K_END |  | end
K_PAGEUP |  | page up
K_PAGEDOWN |  | page down
K_F1 |  | F1
K_F2 |  | F2
K_F3 |  | F3
K_F4 |  | F4
K_F5 |  | F5
K_F6 |  | F6
K_F7 |  | F7
K_F8 |  | F8
K_F9 |  | F9
K_F10 |  | F10
K_F11 |  | F11
K_F12 |  | F12
K_F13 |  | F13
K_F14 |  | F14
K_F15 |  | F15
K_NUMLOCK |  | numlock
K_CAPSLOCK |  | capslock
K_SCROLLOCK |  | scrollock
K_RSHIFT |  | right shift
K_LSHIFT |  | left shift
K_RCTRL |  | right ctrl
K_LCTRL |  | left ctrl
K_RALT |  | right alt
K_LALT |  | left alt
K_RMETA |  | right meta
K_LMETA |  | left meta
K_LSUPER |  | left windows key
K_RSUPER |  | right windows key
K_MODE |  | mode shift
K_HELP |  | help
K_PRINT |  | print-screen
K_SYSREQ |  | SysRq
K_BREAK |  | break
K_MENU |  | menu
K_POWER |  | power
K_EURO |  | euro

modifiers
`pygame.constants.modifiers (constants)`

Their states are treated slightly differently than normal keyboard button states, and you can temporarily set their states.
KMOD_NONE, KMOD_LSHIFT, KMOD_RSHIFT, KMOD_SHIFT, KMOD_CAPS,
KMOD_LCTRL, KMOD_RCTRL, KMOD_CTRL, KMOD_LALT, KMOD_RALT,
KMOD_ALT, KMOD_LMETA, KMOD_RMETA, KMOD_META, KMOD_NUM, KMOD_MODE

zdepracated
`pygame.constants.zdepracated (constants)`

The flags labeled as readonly should never be used, except when comparing checking flags against Surface.get_flags().
SWSURFACE - not really usable as a surface flag, equates to 0 and is always default
ANYFORMAT - creates a display with in best possible bit depth
HWACCEL - surface is hardware accelerated, readonly
SRCCOLORKEY- surface has a colorkey for blits, readonly
SRCALPHA - surface has alpha enabled, readonly
RLEACCELOK - surface is rle accelrated but uncompiled, readonly