Perhaps you can use / proc, namely / proc / bus / input / devices to get a list of available keyboard devices. This is a list of devices with a “keyboard” in their names taken from my laptop (I have a USB keyboard connected, so the answer to your second question is “yes”):
I: Bus=0011 Vendor=0001 Product=0001 Version=ab54 N: Name="AT Translated Set 2 keyboard" P: Phys=isa0060/serio0/input0 S: Sysfs=/devices/platform/i8042/serio0/input/input0 U: Uniq= H: Handlers=sysrq kbd event0 B: EV=120013 B: KEY=4 2000000 3803078 f800d001 feffffdf ffefffff ffffffff fffffffe B: MSC=10 B: LED=7 I: Bus=0003 Vendor=04d9 Product=1603 Version=0110 N: Name=" USB Keyboard" P: Phys=usb-0000:00:1d.0-2/input0 S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.0/input/input5 U: Uniq= H: Handlers=sysrq kbd event5 B: EV=120013 B: KEY=10000 7 ff800000 7ff febeffdf f3cfffff ffffffff fffffffe B: MSC=10 B: LED=7 I: Bus=0003 Vendor=04d9 Product=1603 Version=0110 N: Name=" USB Keyboard" P: Phys=usb-0000:00:1d.0-2/input1 S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.1/input/input6 U: Uniq= H: Handlers=kbd event6 B: EV=13 B: KEY=2000000 39fa d941d001 1e0000 0 0 0 B: MSC=10 I: Bus=0003 Vendor=0000 Product=0000 Version=0004 N: Name="ACPI Virtual Keyboard Device" P: Phys= S: Sysfs=/devices/virtual/input/input14 U: Uniq= H: Handlers=sysrq kbd event14 rfkill B: EV=3 B: KEY=ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe
source share