1

I am trying to detect which keyboard is pressed in a console application when there are more than one keyboard inputs.
if there are two keyboards like laptops default keyboard and wireless keyboard is attached in my case if I press any key on any keyboard it shows this.key is press but I need this.key from this keyboard is pressed in this code, it detects only the key

public class Program
{
    public static void Main()
    {

        ConsoleKeyInfo keyinfo;
        do
        {
            keyinfo = Console.ReadKey();
            Console.WriteLine(keyinfo.Key + " was pressed" + );
        }
        while (keyinfo.Key != ConsoleKey.X);
    }
}
AK856
  • 33
  • 5
  • what do you expect to detect ? ofcourse it will detect the one key at a time – Ehsan Sajjad Aug 19 '19 at 04:57
  • I want to detect the keyboard device which is pressed @EhsanSajjad – AK856 Aug 19 '19 at 05:00
  • @TheGeneral afaik there is, let me try and find it. I closed this as a duplicate. Here is *one of* the methods: http://www.oblita.com/interception.html – Jeremy Thompson Aug 19 '19 at 05:04
  • there is any way to get detailed key info @TheGeneral – AK856 Aug 19 '19 at 05:06
  • how have you plugged in these keyboards? – TheGeneral Aug 19 '19 at 05:06
  • This was the article that I was thinking of: https://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard – Jeremy Thompson Aug 19 '19 at 05:09
  • 1
    @JeremyThompson nice find – TheGeneral Aug 19 '19 at 05:09
  • I am trying to display the device which is pressed @JeremyThompson – AK856 Aug 19 '19 at 05:25
  • `I want to detect the keyboard device which is pressed` Can you talk us through **why** you want to do that? Why do you care if the key came from keyboard 1 vs keyboard 2? – mjwills Aug 19 '19 at 05:27
  • I am creating an app that has two streams they have two playback devices. For controlling those media which makes a change on both playback devices. if I can detect the keyboard device separated the input control can also be separated without interruption of one another @mjwills sry for my poor english – AK856 Aug 19 '19 at 05:35

0 Answers0