I'm having a problem with the KEYDOWN event. for some reason it causes repeat inputs when I'm holding down a button. here's my code:
import pygame
def main():
pygame.init()
pygame.display.set_caption("minimal program")
screen = pygame.display.set_mode((240,180))
running = True
pygame.key.set_repeat()
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
running = False
if event.type == pygame.KEYDOWN:
print("pressed")
if __name__=="__main__":
main()
I tried to use pygame.key.set_repeat() and it didn't work. I also opened a new file to check if something is wrong with my current file and nothing changed. if anyone knows the reason for this please help.
Edit: after a ton of checks and restarting I noticed that if I restart jupyter (it's where I write my code) the first run won't have this problem, but all the ones after that will, untill I restart again. I realized that for some reason the pygame.quit() function ruins the KEYDOWN and makes the error I described above (I deleted this line and everything worked fine).
If anyone has any idea why this happens please explain it to me