如何在pygame、event.key中使用letter/number组合?
How to use letter/number combinations in pygame, event.key?
我知道在 pygame 中,对于命令:
if event.key==K_r:
当您按下键盘上的字母 r 时,您会得到响应。但我想将点唱机的复杂性增加到 letter/number 组合。所以我尝试了:
if event.key==K_r3:
然后我按了 r,然后按了 3。但是我得到一个错误:名称 'K_r3' 未定义。我希望我不必为每个可能的 letter/number 组合写出定义。有什么建议吗?
`别担心 Rico,这里有答案。尝试以下操作:
if event.type == KEYDOWN:
#this says that a key was pressed down
keys = pygame.key.get_pressed()
#this is a list of all the keys that were pressed down. now, if you want to do do multiple keys, the answer is as follows:
if keys[K_3] and keys[K_r]:
(function)
我希望这能帮助你追求 pygame 伟大。
我知道在 pygame 中,对于命令:
if event.key==K_r:
当您按下键盘上的字母 r 时,您会得到响应。但我想将点唱机的复杂性增加到 letter/number 组合。所以我尝试了:
if event.key==K_r3:
然后我按了 r,然后按了 3。但是我得到一个错误:名称 'K_r3' 未定义。我希望我不必为每个可能的 letter/number 组合写出定义。有什么建议吗?
`别担心 Rico,这里有答案。尝试以下操作:
if event.type == KEYDOWN:
#this says that a key was pressed down
keys = pygame.key.get_pressed()
#this is a list of all the keys that were pressed down. now, if you want to do do multiple keys, the answer is as follows:
if keys[K_3] and keys[K_r]:
(function)
我希望这能帮助你追求 pygame 伟大。