Microsoft DirectX 8.1 (Visual Basic)

Step 3: Gaining Access to the Keyboard

After your application sets the keyboard's behavior, it can acquire access to the device by calling the DirectInputDevice8.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.

You are now ready to begin receiving data from the keyboard. This is shown in Step 4: Retrieving Immediate Data from the Keyboard.