#timers/buttons import pygame import sys from pygame.locals import * pygame.init() DISPLAYWINDOWSIZE = pygame.display.set_mode((600, 400)) pygame.display.set_caption("Test") clock = pygame.time.Clock() current_time = 0 button_press_time = 0 while True : for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: button_press_time = pygame.time.get_ticks() current_time = pygame.time.get_ticks() if current_time - button_press_time > 500: DISPLAYWINDOWSIZE.fill((0, 0, 0)) else: DISPLAYWINDOWSIZE.fill((255, 255, 255)) if current_time == button_press_time: print("Pressed button!!!!") print(f"curremt time: {current_time} button press time: {button_press_time}") pygame.display.flip() clock.tick(60)