import pygame from pygame.locals import * import sys pygame.init() display = pygame.display.set_mode((500,500)) while 1: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pressed_keys = pygame.key.get_pressed() if pressed_keys[K_a]: print("Key A has been pressed :D") if event.type == pygame.KEYUP: if event.key == pygame.K_a: print("Key A has been released :d") if pressed_keys[K_SPACE]: print("The spacebar has been pressed :D") if event.type == pygame.KEYUP: if event.key == pygame.K_SPACE: print("The spacebar has been released :d")