Tag: and the code to do so is called an event handler. Every event in pygame has an event type associated with it. For your game

Processing Events

Processing Events