I'm working on learning on programming with Pygame by following a tutorial linked from the Pygame site. I seem to have stuck myself in a hole, however, because I can't seem to set keys to do different things within the program. I'm trying to first close the program by pressing the ESC button, but can't seem to find the proper code to do so. Here's what I have so far

##Import Modules
import pygame, sys,os
from pygame.locals import *

##Initialize Pygame

##Set Up Screen
window = pygame.display.set_mode((468, 60))
pygame.display.set_caption('Python Tut')
screen = pygame.display.get_surface()

##Construct Monkey Filename
monkey_head_file_name = os.path.join("C:\\Users\\family\Desktop\Arin'sstuff\Programs\pygametut", "chimp.bmp")

##Loading Monkey Head image
monkey_surface = pygame.image.load(monkey_head_file_name)

## Drawing monkey on screen
screen.blit (monkey_surface, (0,0))

##flipping the display

##Adding a way to quit
def input(events): 
   for event in events: 
      if (input(event.key.get_pressed(K_ESCAPE)) == True) or (event.type == QUIT): 
         print event  

##The Main loop
while True: 

if event.type == QUIT , I can set the sys.exit(0) to if (event.type == KEYDOWN) or (event.type == QUIT , without a problem. But, how do I use a specific key? I went through most of the site's Python code snippets without finding anything, and search the documentation for Pygame and Python to no avail. Thanks in advance for any help.

Cool. I'd seen the Pygame keys, but they do no good if you don 't know what to do with them. Thank you!

This question has already been answered. Start a new discussion instead.