I have 2 keyboards hooked up to my machine (one on PS/2, the other on USB). How would I determine which keyboard is sending the keystrokes in C#?
Ok, here's a really kludgy method that would only work with a very limited subset of use cases:
Limitations:
Unknown #1: whether ModifierKeys is only populated from the keyboard that was the source of the key click, or comes from the sum of all modifiers across all connected keyboards. I suspect each keyboard internally sends the modifiers attached to the keystroke and that Windows doesn't aggregate them.
Unknown #2: whether or not System.Windows.Forms.Control.ModifierKeys provides only Ctrl/Shift/Alt bits, or provides enough detail to, say, distinguish the Right Ctrl key from the left. Here are the keys you could theoretically test for, I don't know how many are provided via ModifierKeys:
http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx