-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeymap.py
More file actions
111 lines (101 loc) · 2.83 KB
/
Keymap.py
File metadata and controls
111 lines (101 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Astral - A VSRG (Vertical Scrolling Rhythm Game) developed in Python3.
# This program can be found on GitHub: https://github.com/RenderingByte/Astral
# This file serves as a way to provide a conventional keymap for the program.
# Imports
import Globals
import pygame.key
# Initialization
pygame.init()
# Keymap Object (read-only)
keymap = {
"left" : pygame.K_LEFT,
"right" : pygame.K_RIGHT,
"up" : pygame.K_UP,
"down" : pygame.K_DOWN,
"a" : pygame.K_a,
"b" : pygame.K_b,
"c" : pygame.K_c,
"d" : pygame.K_d,
"e" : pygame.K_e,
"f" : pygame.K_f,
"g" : pygame.K_g,
"h" : pygame.K_h,
"i" : pygame.K_i,
"j" : pygame.K_j,
"k" : pygame.K_k,
"l" : pygame.K_l,
"m" : pygame.K_m,
"n" : pygame.K_n,
"o" : pygame.K_o,
"p" : pygame.K_p,
"q" : pygame.K_q,
"r" : pygame.K_r,
"s" : pygame.K_s,
"t" : pygame.K_t,
"u" : pygame.K_u,
"v" : pygame.K_v,
"w" : pygame.K_w,
"x" : pygame.K_x,
"y" : pygame.K_y,
"z" : pygame.K_z,
"0" : pygame.K_0,
"1" : pygame.K_1,
"2" : pygame.K_2,
"3" : pygame.K_3,
"4" : pygame.K_4,
"5" : pygame.K_5,
"6" : pygame.K_6,
"7" : pygame.K_7,
"8" : pygame.K_8,
"9" : pygame.K_9,
"+" : pygame.K_PLUS,
"-" : pygame.K_MINUS,
"." : pygame.K_PERIOD,
"," : pygame.K_COMMA,
"/" : pygame.K_SLASH,
";" : pygame.K_SEMICOLON,
"'" : pygame.K_QUOTE,
"[" : pygame.K_LEFTBRACKET,
"]" : pygame.K_RIGHTBRACKET,
" " : pygame.K_SPACE,
"backspace" : pygame.K_BACKSPACE,
"tab" : pygame.K_TAB,
"capslock" : pygame.K_CAPSLOCK,
"shift" : pygame.K_LSHIFT,
"ctrl" : pygame.K_LCTRL,
"alt" : pygame.K_LALT,
"pause" : pygame.K_PAUSE,
"insert" : pygame.K_INSERT,
"home" : pygame.K_HOME,
"pageup" : pygame.K_PAGEUP,
"pagedown" : pygame.K_PAGEDOWN,
"end" : pygame.K_END,
"del" : pygame.K_DELETE,
"menu" : pygame.K_MENU,
"numlock" : pygame.K_NUMLOCK,
"scrolllock" : pygame.K_SCROLLOCK,
"printscreen" : pygame.K_PRINT,
"f1" : pygame.K_F1,
"f2" : pygame.K_F2,
"f3" : pygame.K_F3,
"f4" : pygame.K_F4,
"f5" : pygame.K_F5,
"f6" : pygame.K_F6,
"f7" : pygame.K_F7,
"f8" : pygame.K_F8,
"f9" : pygame.K_F9,
"f10" : pygame.K_F10,
"f11" : pygame.K_F11,
"f12" : pygame.K_F12,
}
def GetKey(key):
"""
Looks up a given character in the keymap and returns the corresponding object.
That object will be in a Pygame Key object format. (e.g. pygame.K_a)
';' will return pygame.K_SEMICOLON.
Mainly used for setting keybinds.
"""
if key in keymap: return keymap[key]
else:
print("\033[91mSorry, but your key: '", key, "' is currently not an available keybind. Please choose something else!")
Globals.program.isRunning = False