20 (pygame
.K_ESCAPE
, 'ESC', 'first', 0, {}),
22 (pygame
.K_F1
, 'F1', 'first', 100, {}),
23 (pygame
.K_F2
, 'F2', 'first', 150, {}),
24 (pygame
.K_F3
, 'F3', 'first', 200, {}),
25 (pygame
.K_F4
, 'F4', 'first', 250, {}),
27 (pygame
.K_F5
, 'F5', 'first', 325, {}),
28 (pygame
.K_F6
, 'F6', 'first', 375, {}),
29 (pygame
.K_F7
, 'F7', 'first', 425, {}),
30 (pygame
.K_F8
, 'F8', 'first', 475, {}),
32 (pygame
.K_F9
, 'F9', 'first', 550, {}),
33 (pygame
.K_F10
, 'F10', 'first', 600, {}),
34 (pygame
.K_F11
, 'F11', 'first', 650, {}),
35 (pygame
.K_F12
, 'F12', 'first', 700, {}),
38 (178, '²', 'second', 0, {}),
39 (pygame
.K_AMPERSAND
, '&', 'second', 50, {}),
40 (233, 'é', 'second', 100, {}),
41 (pygame
.K_QUOTEDBL
, '"', 'second', 150, {}),
42 (pygame
.K_QUOTE
, "'", 'second', 200, {}),
43 (pygame
.K_LEFTPAREN
, '(', 'second', 250, {}),
44 (pygame
.K_MINUS
, '-', 'second', 300, {}),
45 (232, 'è', 'second', 350, {}),
46 (pygame
.K_UNDERSCORE
, '_', 'second', 400, {}),
47 (231, 'ç', 'second', 450, {}),
48 (224, 'à', 'second', 500, {}),
49 (pygame
.K_RIGHTPAREN
, ')', 'second', 550, {}),
50 (pygame
.K_EQUALS
, '=', 'second', 600, {}),
52 (pygame
.K_BACKSPACE
, '<-', 'second', 650, { 'width': 98 }
),
55 (pygame
.K_TAB
, 'tab', 'third', 0, { 'width' : 73 }
),
56 (pygame
.K_a
, 'a', 'third', 75, {}),
57 (pygame
.K_z
, 'z', 'third', 125, {}),
58 (pygame
.K_e
, 'e', 'third', 175, {}),
59 (pygame
.K_r
, 'r', 'third', 225, {}),
60 (pygame
.K_t
, 't', 'third', 275, {}),
61 (pygame
.K_y
, 'y', 'third', 325, {}),
62 (pygame
.K_u
, 'u', 'third', 375, {}),
63 (pygame
.K_i
, 'i', 'third', 425, {}),
64 (pygame
.K_o
, 'o', 'third', 475, {}),
65 (pygame
.K_p
, 'p', 'third', 525, {}),
66 (pygame
.K_CARET
, '^', 'third', 575, {}),
67 (pygame
.K_DOLLAR
, '$', 'third', 625, {}),
69 (pygame
.K_RETURN
, 'Enter', 'third', 692, { 'width': 56, 'height': 98 }
),
71 (pygame
.K_CAPSLOCK
, 'CAPS', 'fourth', 0, { 'width': 88, 'disabled': True }
),
73 (pygame
.K_q
, 'q', 'fourth', 90, {}),
74 (pygame
.K_s
, 's', 'fourth', 140, {}),
75 (pygame
.K_d
, 'd', 'fourth', 190, {}),
76 (pygame
.K_f
, 'f', 'fourth', 240, {}),
77 (pygame
.K_g
, 'g', 'fourth', 290, {}),
78 (pygame
.K_h
, 'h', 'fourth', 340, {}),
79 (pygame
.K_j
, 'j', 'fourth', 390, {}),
80 (pygame
.K_k
, 'k', 'fourth', 440, {}),
81 (pygame
.K_l
, 'l', 'fourth', 490, {}),
82 (pygame
.K_m
, 'm', 'fourth', 540, {}),
83 (249, 'ù', 'fourth', 590, {}),
84 (pygame
.K_ASTERISK
, '*', 'fourth', 640, {}),
87 (pygame
.K_LSHIFT
, 'LShift', 'fifth', 0, { 'width': 63, 'disabled': True }
),
89 (pygame
.K_LESS
, '<', 'fifth', 65, {}),
90 (pygame
.K_w
, 'w', 'fifth', 115, {}),
91 (pygame
.K_x
, 'x', 'fifth', 165, {}),
92 (pygame
.K_c
, 'c', 'fifth', 215, {}),
93 (pygame
.K_v
, 'v', 'fifth', 265, {}),
94 (pygame
.K_b
, 'b', 'fifth', 315, {}),
95 (pygame
.K_n
, 'n', 'fifth', 365, {}),
96 (pygame
.K_COMMA
, ',', 'fifth', 415, {}),
97 (pygame
.K_SEMICOLON
, ';', 'fifth', 465, {}),
98 (pygame
.K_COLON
, ':', 'fifth', 515, {}),
99 (pygame
.K_EXCLAIM
, '!', 'fifth', 565, {}),
101 (pygame
.K_RSHIFT
, 'RShift', 'fifth', 615, { 'width': 133, 'disabled': True }
),
103 (pygame
.K_LCTRL
, 'LCtrl', 'sixth', 0, { 'width': 63, 'disabled': True }
),
104 (pygame
.K_LSUPER
, 'LSuper', 'sixth', 115, { 'disabled': True }
),
105 (pygame
.K_LALT
, 'LAlt', 'sixth', 165, { 'disabled': True }
),
106 (pygame
.K_SPACE
, 'Espace', 'sixth', 215, { 'width': 248 }
),
107 (pygame
.K_MODE
, 'AltGr', 'sixth', 465, { 'disabled': True }
),
108 (314, 'Compose', 'sixth', 515, { 'disabled': True }
),
109 (pygame
.K_RCTRL
, 'RCtrl', 'sixth', 565, { 'width': 63, 'disabled': True }
),
112 (pygame
.K_INSERT
, 'ins', 'second', 755, {}),
113 (pygame
.K_HOME
, 'home', 'second', 805, {}),
114 (pygame
.K_PAGEUP
, 'pg_u', 'second', 855, {}),
115 (pygame
.K_DELETE
, 'del', 'third', 755, {}),
116 (pygame
.K_END
, 'end', 'third', 805, {}),
117 (pygame
.K_PAGEDOWN
, 'pg_d', 'third', 855, {}),
120 (pygame
.K_UP
, 'up', 'fifth', 805, {}),
121 (pygame
.K_DOWN
, 'down', 'sixth', 805, {}),
122 (pygame
.K_LEFT
, 'left', 'sixth', 755, {}),
123 (pygame
.K_RIGHT
, 'right', 'sixth', 855, {}),
126 def __init__(self
, screen
, draw_lock
):
127 self
.draw_lock
= draw_lock
129 self
.background
= pygame
.Surface(self
.SIZE
).convert()
130 self
.background
.fill((250, 250, 250))
133 for key
in self
.KEYS
:
134 if key
[2] in self
.ROW_POSITIONS
:
135 position
= self
.ROW_POSITIONS
[key
[2]]
138 self
.keys
[key
[0]] = Key(self
,
140 key
[0], key
[1], position
, key
[3],
144 for key_name
in self
.keys
:
145 key
= self
.keys
[key_name
]
146 should_redraw_key
= key
.draw(self
.background
)
148 if should_redraw_key
:
149 threading
.Thread(name
= "MSPollRedraw", target
= key
.poll_redraw
, args
= [self
.background
]).start()
153 self
.draw_lock
.acquire()
154 self
.screen
.blit(self
.background
, (5, 5))
155 pygame
.display
.flip()
156 self
.draw_lock
.release()
158 def find_by_key_num(self
, key_num
):
159 if key_num
in self
.keys
:
160 return self
.keys
[key_num
]
163 def find_by_collidepoint(self
, position
):
164 for key
in self
.keys
:
165 if self
.keys
[key
].collidepoint(position
):
166 return self
.keys
[key
]
169 def find_by_unicode(self
, key_sym
):
170 for key
in self
.keys
:
171 if self
.keys
[key
].key_sym
== key_sym
:
172 return self
.keys
[key
]
175 def stop_all_running(self
):
178 def start_running(self
, key
, start_time
):
179 self
.running
.append((key
, start_time
))
181 def keep_running(self
, key
, start_time
):
182 return (key
, start_time
) in self
.running
184 def finished_running(self
, key
, start_time
):
185 if (key
, start_time
) in self
.running
:
186 self
.running
.remove((key
, start_time
))