Question

I have two keyboards connected to my PC, is there any way to know what keyboard a key was pressed on in any language or framework?

Was it helpful?

Solution

For Windows, you can register you application to receive raw input notifications with the RegisterRawInputDevices API. Once you register, your application will start receiving WM_INPUT messages. The lParam to that message is a pointer to a RAWINPUT structure. You can use the GetRawInputData API to get the header in the form of RAWINPUTHEADER structure. Then you can use the GetRawInputDeviceInfo on the device handle from the header to extract information for the device that generated the input.

I am not aware of other ways to get the device that generated the keyboard input on Windows.

I also have no idea how to address that problem on any other operating systems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top