pygame을 이용해 패드 컨트롤러 같은 걸 만드려고 하는데, 방향키만 입력이 되고 스페이스와 나머지 키들은 입력이 안 됩니다. 왜 그럴까요? 코드는 이렇습니다.
import pygame
import sys
import keyboard
from pygame.locals import QUIT
pygame.init()
pygame.display.set_caption("Test Window")
Surface = pygame.display.set_mode((600,600))
FPSCLOCK = pygame.time.Clock()
def main():
while True:
Surface.fill((0,0,0))
c1=255
c2=255
c3=255
c4=255
c5=255
c6=255
c7=255
c8=255
c9=255
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
c1 = 100
elif event.key == pygame.K_RIGHT:
c2 = 20
elif event.key == pygame.K_UP:
c3 = 80
elif event.key == pygame.K_DOWN:
c4 = 40
elif event.key == pygame.K_SPACE:
c5 = 10
elif event.key == pygame.K_w:
c6 = 75
elif event.key == pygame.K_a:
c7 = 40
elif event.key == pygame.K_s:
c8 = 100
elif event.key == pygame.K_d:
c9 = 200
pygame.draw.rect(Surface,(255,c1,255),(15,15,180,180))
pygame.draw.rect(Surface,(c3,255,255),(210,15,180,180))
pygame.draw.rect(Surface,(255,255,c2),(405,15,180,180))
pygame.draw.rect(Surface,(c4,c4,255),(15,210,180,180))
pygame.draw.rect(Surface,(255,c5,c5),(210,210,180,180))
pygame.draw.rect(Surface,(c6,255,c6),(405,210,180,180))
pygame.draw.rect(Surface,(255,c7,c7),(15,405,180,180))
pygame.draw.rect(Surface,(255,c8,c8),(210,405,180,180))
pygame.draw.rect(Surface,(c9,255,255),(405,405,180,180))
pygame.display.update()
FPSCLOCK.tick(120)
if __name__ == '__main__':
main()