Microsoft DirectX 8.1 (Visual Basic)

Step 1: Creating the DirectInput8 Object and the Keyboard Device

The first step in setting up the Microsoft® DirectInput® system is to create a single DirectInput8 object as overall manager. This is done with a call to the DirectX8.DirectInputCreate method, typically in the Load event handler for the main form or in Sub Main.

Dim dx As New DirectX8
Dim di As DirectInput8

Set di = dx.DirectInputCreate()

The keyboard is then created as a standard device by passing the keyboard GUID alias to DirectInput8.CreateDevice.

Dim didev As DirectInputDevice8
Set didev = di.CreateDevice("GUID_SysKeyboard")

Once the keyboard device is created, its methods will be used to set its data format and cooperative level in Step 2: Setting the Keyboard Parameters.