[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] BUG: pygame.event.get(pygame.KEYDOWN) fails



Tested under Linux. (Python 2.5.4, pygame 1.7.1 release 4.2 from Debian)
and Windows. (with a slightly older version of python/pygame)

The code pygame.event.get(pygame.KEYDOWN) does not work correctly. If
called in this manner, it will work, but only for the first 100 or so
keypresses. After a certain point, the get() function will no longer
return the appropriate events, and will instead return an empty list, no
matter what the physical input. pygame.event.get() functions properly.

Below is some test code. When running the first program, the counter
tends to stop at around 120. The 2nd program, which should be identical,
functions as expected.



#Broken
import pygame
pygame.init()
screen = pygame.display.set_mode((640, 480))
counter = 0
while 1:
    pygame.time.wait(60)
    for event in pygame.event.get(pygame.KEYDOWN):
        counter +=1
        print counter

-----------

#Works
import pygame
pygame.init()
screen = pygame.display.set_mode((640, 480))
counter = 0
while 1:
    pygame.time.wait(60)
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            counter +=1
            print counter