Chapter 18. A New Kind of Input—Events

Up until now, we have had very simple kinds of inputs for our programs. The user either 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! Computer Programming for Kids and Other Beginners now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.