Chapter 18. A New Kind of Input—Events

Up until now, we have had very simple kinds of inputs for our programs. Either the user typed in strings using raw_input(), or we got numbers and strings from EasyGui (in chapter 6). I also showed you how you could use the mouse to close a Pygame window, but I didn’t really explain how that worked.

In this chapter, you’ll learn about a different kind of input called events. Along the way, we’ll look at exactly what the exit code for the Pygame window is doing and how it works. We’ll also get input from the mouse and make our programs react immediately to a key being pressed, without having to wait for the user to press Enter.

Events

If I asked you, “What’s an event?” in real life, you might say that ...

Get Hello World! Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.