O'Reilly logo

Beginning Java SE 6 Game Programming, Third Edition by Jonathan S. Harbour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Keyboard and Mouse Input

The keyboard and mouse are the only realistic devices for user input in a Java game, regardless of whether it’s a web-based applet or a standalone application. But even when considering a standard Windows-based game developed in DirectX or another library, the keyboard and mouse are by far the most common forms of user interaction in a game. This chapter covers the important subject of handling user input.

Here are the key topics you will learn in this chapter:

  • Listening for keyboard events

  • Testing keyboard input

  • Displaying key presses

  • Reading mouse motion

  • Detecting mouse buttons

  • Testing mouse input

Listening to the User

Java provides an interesting way to interact with users through a series of listener methods. You ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required