Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@illume
Created February 14, 2021 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illume/b4681bb4adfd95355a70eb5e8fb4bb52 to your computer and use it in GitHub Desktop.
Save illume/b4681bb4adfd95355a70eb5e8fb4bb52 to your computer and use it in GitHub Desktop.
press g key, see key repeat is slow. Press f key, then pressing g key means the key repeat is fast (broken).
"""
Manual test for pygame #2100
Press F to quit and restart the screen
"""
import pygame
#pygame.init() # <- problem doesn't happen at all with this
screen = pygame.display.set_mode([500, 500])
clock = pygame.time.Clock()
pygame.key.set_repeat(500,500)
while True:
screen.fill((255,0,255))
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
raise SystemExit
if event.type == pygame.KEYDOWN:
print(event)
if event.key == pygame.K_f:
pygame.display.quit() # <- works fine without this line
screen = pygame.display.set_mode([500, 500])
# pygame.key.set_repeat(500,500) <- no impact on result for pygame 2 - necessary to pygame 1
if event.key == pygame.K_g:
print(pygame.key.get_repeat()) # still returns (500, 500) after quit and init
clock.tick(60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment