Building Interactive Systems with Keyboard Events

So far in this book, our code has been very linear—it follows a straight line. First we made a cover, a shape, and a mesh, and then we added the objects to the scene. Then we moved to the next mesh, which was also added to the scene. Although it is possible to write a lot of JavaScript that looks like this, most JavaScript programs tend to be quite different.

That’s because JavaScript usually runs in a web browser. In a web browser, JavaScript code has to respond to events. A key being pressed on the keyboard, a mouse button being clicked, and the mouse pointer moving around the page are all events in the web browser. A crazy number of events can potentially happen on every web page, and for ...

Get 3D Game Programming for Kids 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.