The pygame.key.get_pressed() function seems not to be working as expected on my Mac OSX (10.11.1) using Python 3 and Pygame.
After importing pygame and the time module I check if the w key (pygame.K_w) is pressed by using a simple if-statement and Pygames pygame.key.get_pressed() function.
But the test fails and It didn't work is printed very time:
#!/usr/bin/env python3
import pygame, time
pygame.init()
while True:
keypressed = pygame.key.get_pressed()
time.sleep(5)
print("5 seconds later")
if keypressed[pygame.K_w]:
print("it worked")
else:
print("It didn't work")