I've read similar questions to this on Stack Overflow but they have not helped. Here is my code:
import pygame
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('Hello World')
pygame.mouse.set_visible(1)
done = False
clock = pygame.time.Clock()
while not done:
clock.tick(60)
keyState = pygame.key.get_pressed()
if keyState[pygame.K_ESCAPE]:
print('
Game Shuting Down!')
done = True
Pressing escape
does not exit the game or print a message. Is this a bug? If I print the value for keyState[pygame.K_ESCAPE], it is always zero.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…