DirectX SDK

Tutorial 1: Using the Keyboard

[Visual Basic]

The information in this topic pertains only to applications written in C++. See DirectInput Visual Basic Tutorials.

[C++]

To prepare for keyboard input, you first create an instance of a DirectInput object. Then you use the IDirectInput7::CreateDeviceEx method to create an instance of an IDirectInputDevice7 interface. The IDirectInputDevice7 interface methods are used to manipulate the device, set its behavior, and retrieve data.

The tutorial breaks down the required tasks into the following steps:

Adding DirectInput keyboard support to an application is relatively simple, so this tutorial is not accompanied by a complete sample application. All of the tutorial steps are illustrated by code within the text. The related steps for initializing the system are gathered in Sample Function 1: DI_Init. Another function, Sample Function 2: DI_Term, is called whenever the system needs to be closed down.