Step 5: Gaining Access to the Keyboard

After your application sets the keyboard's behavior, it can acquire access to the device by calling the IDirectInputDevice::Acquire method. The application must acquire the device before retrieving data from it. The Acquire method accepts no parameters.

The following line of code acquires the keyboard device that was created in Step 2: Creating the DirectInput Keyboard Device:

if (g_lpDIDevice) g_lpDIDevice->Acquire();