Very nice question... I have 2 keyboards connected to a computer like distinguishing a key pressed in each one in VB6?

     one keyboard is connected in the ps2 port, and other keyboard in the usb port, because this... good this is for receive the survey of one customer.

   Some can give me one tip of how make this. ??

 Thank you before hand.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I would suspect that DirectInput could be used.

You could add the DirectX 7 for VB reference to your project, then define the following:

Dim DX As New DirectX7
Dim DI As DirectInput
Dim DEnum As DirectInputEnumDevices

Then enumerate the keyboards:

Set DI = DX.DirectInputCreate

You can use DEnum.GetItem(i) to retrieve info on a keyboard, then use DirectX Events to retrieve the keypresses. When the keys are pressed, the GUID passed by the event should be checked against the return value of GetGUIDInstance for each item in DEnum.
ppeniaAuthor Commented:

 Thanks burningmace.

   I tried this solution but i have some problems, i type this code..

Dim DX As New DirectX
Dim DI As DirectInput
Dim DEnum As DirectInputEnumDevices

Private Sub Command1_Click()

     MsgBox DEnum.GetCount  ' this return 1 is correct ?????

End Sub

Private Sub Form_Load()

Set DI = DX.DirectInputCreate

End Sub

  How can evaluate the keypresses in each keyboard with Events DirectX ?
  You can post  one source code more explicit please ?

 Thank you for you assitance and time.

Well if it's only returning 1, then you don't have both keyboards plugged in... either that or there is a problem.


As for doing keyboard events in VB using DirectX, I've not done it before, so I'm not sure.

There's a good lot of code for C++ here:
You just need to sort of "translate it" across to VB.

Another for C++:

Unfortunately, not many people want to do DirectInput for VB. I can't spot anything decent.

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.