📜  如何检测pygame中何时按下键 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:41.434000             🧑  作者: Mango

代码示例3
import pygame

keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
    x -= 1
if keys[pygame.K_RIGHT]:
    x += 1