Table of Contents

Class KeyCode

Namespace
Gym.Rendering
Assembly
Gym.Rendering.dll

The keycodes pygame puts in a key event's key (SDL2's SDL_Keycode), by readable names: Left is pygame's K_LEFT. Use them in a keys_to_action mapping for Play, and in an IInteractiveEnvViewer that translates its framework's keys.

public static class KeyCode
Inheritance
KeyCode
Inherited Members

Remarks

A key that types a character has that character's code, unshifted (A is 97 for a and A alike); every other key is its USB scancode with bit 30 set (ScancodeMask), so the arrows are above a billion. pygame 1's codes are gone: MountainCar's get_keys_to_action still names 275 and 276, pygame 1's arrows, which no pygame 2 window produces.

The values were read from live pygame-ce 2.5.8 (SDL 2.32.10). The viewers report the keyboard layout's key, as pygame does (DR-47): the key labeled A is A on any layout; the punctuation keys are named as on a US layout.

Reference: src_c/constants.c (pygame-ce 2.5.8).

Fields

A

The letter key a (lower case whatever the shift state), pygame's K_a (97).

public const int A = 97

Field Value

int

Ampersand

&, pygame's K_AMPERSAND (38).

public const int Ampersand = 38

Field Value

int

Asterisk

*, pygame's K_ASTERISK (42).

public const int Asterisk = 42

Field Value

int

At

@, pygame's K_AT (64).

public const int At = 64

Field Value

int

B

The letter key b (lower case whatever the shift state), pygame's K_b (98).

public const int B = 98

Field Value

int

Backquote

`, pygame's K_BACKQUOTE (96).

public const int Backquote = 96

Field Value

int

Backslash

</code>, pygame's K_BACKSLASH (92).

public const int Backslash = 92

Field Value

int

Backspace

Backspace, pygame's K_BACKSPACE (8).

public const int Backspace = 8

Field Value

int

C

The letter key c (lower case whatever the shift state), pygame's K_c (99).

public const int C = 99

Field Value

int

CapsLock

Caps Lock, pygame's K_CAPSLOCK: scancode 57 with bit 30 set (1073741881).

public const int CapsLock = 1073741881

Field Value

int

Caret

^, pygame's K_CARET (94).

public const int Caret = 94

Field Value

int

Colon

:, pygame's K_COLON (58).

public const int Colon = 58

Field Value

int

Comma

,, pygame's K_COMMA (44).

public const int Comma = 44

Field Value

int

D

The letter key d (lower case whatever the shift state), pygame's K_d (100).

public const int D = 100

Field Value

int

Delete

Delete, pygame's K_DELETE (127).

public const int Delete = 127

Field Value

int

Digit0

The digit 0 on the main keyboard, pygame's K_0 (48).

public const int Digit0 = 48

Field Value

int

Digit1

The digit 1 on the main keyboard, pygame's K_1 (49).

public const int Digit1 = 49

Field Value

int

Digit2

The digit 2 on the main keyboard, pygame's K_2 (50).

public const int Digit2 = 50

Field Value

int

Digit3

The digit 3 on the main keyboard, pygame's K_3 (51).

public const int Digit3 = 51

Field Value

int

Digit4

The digit 4 on the main keyboard, pygame's K_4 (52).

public const int Digit4 = 52

Field Value

int

Digit5

The digit 5 on the main keyboard, pygame's K_5 (53).

public const int Digit5 = 53

Field Value

int

Digit6

The digit 6 on the main keyboard, pygame's K_6 (54).

public const int Digit6 = 54

Field Value

int

Digit7

The digit 7 on the main keyboard, pygame's K_7 (55).

public const int Digit7 = 55

Field Value

int

Digit8

The digit 8 on the main keyboard, pygame's K_8 (56).

public const int Digit8 = 56

Field Value

int

Digit9

The digit 9 on the main keyboard, pygame's K_9 (57).

public const int Digit9 = 57

Field Value

int

Dollar

$, pygame's K_DOLLAR (36).

public const int Dollar = 36

Field Value

int

Down

The down arrow, pygame's K_DOWN: scancode 81 with bit 30 set (1073741905).

public const int Down = 1073741905

Field Value

int

E

The letter key e (lower case whatever the shift state), pygame's K_e (101).

public const int E = 101

Field Value

int

End

End, pygame's K_END: scancode 77 with bit 30 set (1073741901).

public const int End = 1073741901

Field Value

int

EqualsSign

= (named so it does not hide object.Equals), pygame's K_EQUALS (61).

public const int EqualsSign = 61

Field Value

int

Escape

Escape, which also ends play, pygame's K_ESCAPE (27).

public const int Escape = 27

Field Value

int

Exclaim

!, pygame's K_EXCLAIM (33).

public const int Exclaim = 33

Field Value

int

F

The letter key f (lower case whatever the shift state), pygame's K_f (102).

public const int F = 102

Field Value

int

F1

The function key F1, pygame's K_F1: scancode 58 with bit 30 set (1073741882).

public const int F1 = 1073741882

Field Value

int

F10

The function key F10, pygame's K_F10: scancode 67 with bit 30 set (1073741891).

public const int F10 = 1073741891

Field Value

int

F11

The function key F11, pygame's K_F11: scancode 68 with bit 30 set (1073741892).

public const int F11 = 1073741892

Field Value

int

F12

The function key F12, pygame's K_F12: scancode 69 with bit 30 set (1073741893).

public const int F12 = 1073741893

Field Value

int

F13

The function key F13, pygame's K_F13: scancode 104 with bit 30 set (1073741928).

public const int F13 = 1073741928

Field Value

int

F14

The function key F14, pygame's K_F14: scancode 105 with bit 30 set (1073741929).

public const int F14 = 1073741929

Field Value

int

F15

The function key F15, pygame's K_F15: scancode 106 with bit 30 set (1073741930).

public const int F15 = 1073741930

Field Value

int

F2

The function key F2, pygame's K_F2: scancode 59 with bit 30 set (1073741883).

public const int F2 = 1073741883

Field Value

int

F3

The function key F3, pygame's K_F3: scancode 60 with bit 30 set (1073741884).

public const int F3 = 1073741884

Field Value

int

F4

The function key F4, pygame's K_F4: scancode 61 with bit 30 set (1073741885).

public const int F4 = 1073741885

Field Value

int

F5

The function key F5, pygame's K_F5: scancode 62 with bit 30 set (1073741886).

public const int F5 = 1073741886

Field Value

int

F6

The function key F6, pygame's K_F6: scancode 63 with bit 30 set (1073741887).

public const int F6 = 1073741887

Field Value

int

F7

The function key F7, pygame's K_F7: scancode 64 with bit 30 set (1073741888).

public const int F7 = 1073741888

Field Value

int

F8

The function key F8, pygame's K_F8: scancode 65 with bit 30 set (1073741889).

public const int F8 = 1073741889

Field Value

int

F9

The function key F9, pygame's K_F9: scancode 66 with bit 30 set (1073741890).

public const int F9 = 1073741890

Field Value

int

G

The letter key g (lower case whatever the shift state), pygame's K_g (103).

public const int G = 103

Field Value

int

Greater

>, pygame's K_GREATER (62).

public const int Greater = 62

Field Value

int

H

The letter key h (lower case whatever the shift state), pygame's K_h (104).

public const int H = 104

Field Value

int

Hash

#, pygame's K_HASH (35).

public const int Hash = 35

Field Value

int

Home

Home, pygame's K_HOME: scancode 74 with bit 30 set (1073741898).

public const int Home = 1073741898

Field Value

int

I

The letter key i (lower case whatever the shift state), pygame's K_i (105).

public const int I = 105

Field Value

int

Insert

Insert, pygame's K_INSERT: scancode 73 with bit 30 set (1073741897).

public const int Insert = 1073741897

Field Value

int

J

The letter key j (lower case whatever the shift state), pygame's K_j (106).

public const int J = 106

Field Value

int

K

The letter key k (lower case whatever the shift state), pygame's K_k (107).

public const int K = 107

Field Value

int

Keypad0

The keypad's 0 (with Num Lock on), pygame's K_KP_0: scancode 98 with bit 30 set (1073741922).

public const int Keypad0 = 1073741922

Field Value

int

Keypad1

The keypad's 1 (with Num Lock on), pygame's K_KP_1: scancode 89 with bit 30 set (1073741913).

public const int Keypad1 = 1073741913

Field Value

int

Keypad2

The keypad's 2 (with Num Lock on), pygame's K_KP_2: scancode 90 with bit 30 set (1073741914).

public const int Keypad2 = 1073741914

Field Value

int

Keypad3

The keypad's 3 (with Num Lock on), pygame's K_KP_3: scancode 91 with bit 30 set (1073741915).

public const int Keypad3 = 1073741915

Field Value

int

Keypad4

The keypad's 4 (with Num Lock on), pygame's K_KP_4: scancode 92 with bit 30 set (1073741916).

public const int Keypad4 = 1073741916

Field Value

int

Keypad5

The keypad's 5 (with Num Lock on), pygame's K_KP_5: scancode 93 with bit 30 set (1073741917).

public const int Keypad5 = 1073741917

Field Value

int

Keypad6

The keypad's 6 (with Num Lock on), pygame's K_KP_6: scancode 94 with bit 30 set (1073741918).

public const int Keypad6 = 1073741918

Field Value

int

Keypad7

The keypad's 7 (with Num Lock on), pygame's K_KP_7: scancode 95 with bit 30 set (1073741919).

public const int Keypad7 = 1073741919

Field Value

int

Keypad8

The keypad's 8 (with Num Lock on), pygame's K_KP_8: scancode 96 with bit 30 set (1073741920).

public const int Keypad8 = 1073741920

Field Value

int

Keypad9

The keypad's 9 (with Num Lock on), pygame's K_KP_9: scancode 97 with bit 30 set (1073741921).

public const int Keypad9 = 1073741921

Field Value

int

KeypadDivide

The keypad's /, pygame's K_KP_DIVIDE: scancode 84 with bit 30 set (1073741908).

public const int KeypadDivide = 1073741908

Field Value

int

KeypadEnter

The keypad's Enter, pygame's K_KP_ENTER: scancode 88 with bit 30 set (1073741912).

public const int KeypadEnter = 1073741912

Field Value

int

KeypadEquals

The keypad's =, pygame's K_KP_EQUALS: scancode 103 with bit 30 set (1073741927).

public const int KeypadEquals = 1073741927

Field Value

int

KeypadMinus

The keypad's -, pygame's K_KP_MINUS: scancode 86 with bit 30 set (1073741910).

public const int KeypadMinus = 1073741910

Field Value

int

KeypadMultiply

The keypad's *, pygame's K_KP_MULTIPLY: scancode 85 with bit 30 set (1073741909).

public const int KeypadMultiply = 1073741909

Field Value

int

KeypadPeriod

The keypad's ., pygame's K_KP_PERIOD: scancode 99 with bit 30 set (1073741923).

public const int KeypadPeriod = 1073741923

Field Value

int

KeypadPlus

The keypad's +, pygame's K_KP_PLUS: scancode 87 with bit 30 set (1073741911).

public const int KeypadPlus = 1073741911

Field Value

int

L

The letter key l (lower case whatever the shift state), pygame's K_l (108).

public const int L = 108

Field Value

int

Left

The left arrow, pygame's K_LEFT: scancode 80 with bit 30 set (1073741904).

public const int Left = 1073741904

Field Value

int

LeftAlt

The left Alt, pygame's K_LALT: scancode 226 with bit 30 set (1073742050).

public const int LeftAlt = 1073742050

Field Value

int

LeftBracket

[, pygame's K_LEFTBRACKET (91).

public const int LeftBracket = 91

Field Value

int

LeftCtrl

The left Ctrl, pygame's K_LCTRL: scancode 224 with bit 30 set (1073742048).

public const int LeftCtrl = 1073742048

Field Value

int

LeftGui

The left Windows (Command, Super) key, pygame's K_LGUI: scancode 227 with bit 30 set (1073742051).

public const int LeftGui = 1073742051

Field Value

int

LeftParen

(, pygame's K_LEFTPAREN (40).

public const int LeftParen = 40

Field Value

int

LeftShift

The left Shift, pygame's K_LSHIFT: scancode 225 with bit 30 set (1073742049).

public const int LeftShift = 1073742049

Field Value

int

Less

<, pygame's K_LESS (60).

public const int Less = 60

Field Value

int

M

The letter key m (lower case whatever the shift state), pygame's K_m (109).

public const int M = 109

Field Value

int

Menu

The context-menu key, pygame's K_MENU: scancode 118 with bit 30 set (1073741942).

public const int Menu = 1073741942

Field Value

int

Minus

-, pygame's K_MINUS (45).

public const int Minus = 45

Field Value

int

N

The letter key n (lower case whatever the shift state), pygame's K_n (110).

public const int N = 110

Field Value

int

NumLock

Num Lock, pygame's K_NUMLOCK: scancode 83 with bit 30 set (1073741907).

public const int NumLock = 1073741907

Field Value

int

O

The letter key o (lower case whatever the shift state), pygame's K_o (111).

public const int O = 111

Field Value

int

P

The letter key p (lower case whatever the shift state), pygame's K_p (112).

public const int P = 112

Field Value

int

PageDown

Page Down, pygame's K_PAGEDOWN: scancode 78 with bit 30 set (1073741902).

public const int PageDown = 1073741902

Field Value

int

PageUp

Page Up, pygame's K_PAGEUP: scancode 75 with bit 30 set (1073741899).

public const int PageUp = 1073741899

Field Value

int

Pause

Pause (Break), pygame's K_PAUSE: scancode 72 with bit 30 set (1073741896).

public const int Pause = 1073741896

Field Value

int

Percent

%, pygame's K_PERCENT (37).

public const int Percent = 37

Field Value

int

Period

., pygame's K_PERIOD (46).

public const int Period = 46

Field Value

int

Plus

+, pygame's K_PLUS (43).

public const int Plus = 43

Field Value

int

PrintScreen

Print Screen, pygame's K_PRINTSCREEN: scancode 70 with bit 30 set (1073741894).

public const int PrintScreen = 1073741894

Field Value

int

Q

The letter key q (lower case whatever the shift state), pygame's K_q (113).

public const int Q = 113

Field Value

int

Question

?, pygame's K_QUESTION (63).

public const int Question = 63

Field Value

int

Quote

', pygame's K_QUOTE (39).

public const int Quote = 39

Field Value

int

QuoteDbl

", pygame's K_QUOTEDBL (34).

public const int QuoteDbl = 34

Field Value

int

R

The letter key r (lower case whatever the shift state), pygame's K_r (114).

public const int R = 114

Field Value

int

Return

Return (Enter on the main keyboard), pygame's K_RETURN (13).

public const int Return = 13

Field Value

int

Right

The right arrow, pygame's K_RIGHT: scancode 79 with bit 30 set (1073741903).

public const int Right = 1073741903

Field Value

int

RightAlt

The right Alt (AltGr), pygame's K_RALT: scancode 230 with bit 30 set (1073742054).

public const int RightAlt = 1073742054

Field Value

int

RightBracket

], pygame's K_RIGHTBRACKET (93).

public const int RightBracket = 93

Field Value

int

RightCtrl

The right Ctrl, pygame's K_RCTRL: scancode 228 with bit 30 set (1073742052).

public const int RightCtrl = 1073742052

Field Value

int

RightGui

The right Windows (Command, Super) key, pygame's K_RGUI: scancode 231 with bit 30 set (1073742055).

public const int RightGui = 1073742055

Field Value

int

RightParen

), pygame's K_RIGHTPAREN (41).

public const int RightParen = 41

Field Value

int

RightShift

The right Shift, pygame's K_RSHIFT: scancode 229 with bit 30 set (1073742053).

public const int RightShift = 1073742053

Field Value

int

S

The letter key s (lower case whatever the shift state), pygame's K_s (115).

public const int S = 115

Field Value

int

ScancodeMask

The bit SDL sets on the code of a key that types no character (SDLK_SCANCODE_MASK): such a key's code is scancode | ScancodeMask.

public const int ScancodeMask = 1073741824

Field Value

int

ScrollLock

Scroll Lock, pygame's K_SCROLLLOCK: scancode 71 with bit 30 set (1073741895).

public const int ScrollLock = 1073741895

Field Value

int

Semicolon

;, pygame's K_SEMICOLON (59).

public const int Semicolon = 59

Field Value

int

Slash

/, pygame's K_SLASH (47).

public const int Slash = 47

Field Value

int

Space

The space bar, pygame's K_SPACE (32).

public const int Space = 32

Field Value

int

T

The letter key t (lower case whatever the shift state), pygame's K_t (116).

public const int T = 116

Field Value

int

Tab

Tab, pygame's K_TAB (9).

public const int Tab = 9

Field Value

int

U

The letter key u (lower case whatever the shift state), pygame's K_u (117).

public const int U = 117

Field Value

int

Underscore

_, pygame's K_UNDERSCORE (95).

public const int Underscore = 95

Field Value

int

Up

The up arrow, pygame's K_UP: scancode 82 with bit 30 set (1073741906).

public const int Up = 1073741906

Field Value

int

V

The letter key v (lower case whatever the shift state), pygame's K_v (118).

public const int V = 118

Field Value

int

W

The letter key w (lower case whatever the shift state), pygame's K_w (119).

public const int W = 119

Field Value

int

X

The letter key x (lower case whatever the shift state), pygame's K_x (120).

public const int X = 120

Field Value

int

Y

The letter key y (lower case whatever the shift state), pygame's K_y (121).

public const int Y = 121

Field Value

int

Z

The letter key z (lower case whatever the shift state), pygame's K_z (122).

public const int Z = 122

Field Value

int