我是pygame的新手,当我在pygame.window中发布一个鼠标时,它打印出键码c = 99。 我怎么能避免这个错误?
if event.type == pygame.KEYDOWN:
if chr(event.key) in symbols: #and event.key!=99 :
text=text+chr(event.key)
编辑评论代码
import pygame as pg
from pygame import draw, display
pg.init()
depth = 16
m = (640, 480)
display.set_mode(m, 0)
scr = display.get_surface()
pg.display.set_caption("Example")
cl = pg.time.Clock()
sbs = ['a','b','c']
def printT(text):
font = pg.font.Font(None,30)
pr = font.render(t, 1,(255,0,0))
scr.blit(pr, (0, 0))
t = ''
do = True
while do:
cl.tick(80)
for e in pg.event.get():
if e.type == pg.QUIT:
do = False
if e.type == pg.KEYDOWN:
if chr(e.key) in sbs:
t += pg.key.name(e.key)
printT(t)
pg.display.flip()
pg.quit()