The computer keyboard is often used to interact with a game. Later on, in the chapter about the GUI, you will see how to use a keyboard to type in text. This chapter will concentrate on using keystrokes to control interaction with your application.
Every key has a name. Once you know the name, you are able to check on that particular key. Careful though: all names assume a qwerty keyboard. If your keyboard has another layout, like azerty, you will want to keep an image of a qwerty layout at hand. This seems a bit weird, but when controlling a game, the actual position is is more importance than the character shown on the keyboard. For instance: we often use the WASD keys to control movement. Now imagine this would translate to the same characters on an azerty keyboard. That wouldn’t be practical at all!
That said, checking on a keystroke isn’t really much different from a mouse click. You’ll see that most methods are quite similar.