Platform SDK: DirectX

Step 3: Gain Access to the Keyboard

[C++]

This topic pertains only to application development in Visual Basic. See DirectInput C/C++ Tutorials.

[Visual Basic]

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

Call didev.Acquire 
 

In the sample, the application is unlikely to fail to acquire the keyboard, or to lose it later, because it is using the background, nonexclusive cooperative level. However, in general it is good practice to handle errors on calls to Acquire as well as when attempting to retrieve data.

Next: Step 4: Retrieve Immediate Data from the Keyboard