Pygame捕获进入按钮

2024-06-17 13:05:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用pygame捕捉Enter按钮,而不是键盘上的Enter按钮,我想要的是Backspace按钮下的Enter按钮。它们不一样,因为当我按下键盘上的回车键时,其他的回车键就不工作了。

http://www.pygame.org/docs/ref/key.html

有关于按键的文档,但只有键盘输入按钮。我试过这些密码:

This working for keypad Enter button, but other Enter button is not working:

if event.type==pygame.KEYDOWN:
    if event.key==pygame.K_KP_ENTER:
        #some codes

I tried to catch another Enter button with these codes(hopeless):

if event.type==pygame.KEYDOWN:
    if event.key==pygame.K_ENTER:
        #some codes

但当然出现了一个错误:

AttributeError: 'module' object has no attribute 'K_ENTER'

无法理解如何在Backspace下捕获Enter按钮。


Tags: keyeventiftypebutton键盘按钮pygame