# Homework 33, problem 1: key reporter. # # Report which key is currently held. Use pygame.key.get_pressed() to detect # held keys. When no key is held, report "no key". Print the message to the # terminal each frame (text rendering comes in chapter 35). # # Run with: python exercises/33/homework/01-key-reporter.py import pygame pygame.init() screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("Key Reporter") clock = pygame.time.Clock() running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # TODO: check pygame.key.get_pressed() and print the held keys or "no key" screen.fill((30, 30, 30)) pygame.display.flip() clock.tick(10) # slow tick so terminal output is readable pygame.quit()