I have some code to check if "q" is pressed and then I make an instance of a class. The problem is that sometimes it recognizes a press of the button and sometimes it doesn't. For example if I press "q" 10 times, sometimes it will recognize the press 3 times, sometimes 6 times, sometimes 7 times. So how can I fix it so it will recognize the press every single time? Some people said that it's probably because I call pygame.event.get()
multiple times. Because of that I have tried getting events once in the whole script, but it's still the same result.
Code:
pygame.init()
fpsClock = pygame.time.Clock()
screen = pygame.display.set_mode((1920, 1080)
while True:
#Input
self.events = self.pygame.event.get()
for event in self.events:
if event.type == self.QUIT:
self.pygame.quit()
self.sys.exit()
if event.type == self.pygame.KEYDOWN:
if event.key == self.pygame.K_q:
#makes an instance
pygame.display.flip()
fpsClock.tick(60)