Platform SDK: DirectX

Keyboard Data

As far as DirectInput is concerned, the keyboard is not a text input device, but a game pad with many buttons. When your application requires text input, do not use DirectInput methods; it is far easier to retrieve the data from the normal Windows messages, in which you can take advantage of services such as character repeat and translation of physical keys to virtual keys. This is particularly important for languages other than English, which can require special translation of key presses.

[C++]

To set up the keyboard device for data retrieval, you must first call the IDirectInputDevice7::SetDataFormat method with the c_dfDIKeyboard global variable as the parameter. (See Device Data Formats.)

[Visual Basic]

To set up the keyboard device for data retrieval, you must first call the DirectInputDevice.SetCommonDataFormat method with DIFORMAT_KEYBOARD as the parameter.

The following sections give more information about obtaining and interpreting keyboard data: