John Scipione
John Scipione

Reputation: 2392

Is there a way to programmatically check if a Mac or PC keyboard is attached?

Is there a way to reliably check programmatically if the keyboard attached to a computer is a Mac keyboard with Command (⌘) and option keys, or a PC keyboard with Windows, Alt, and Menu keys? For simplicity's sake assume that there is only one keyboard attached to the computer. An operating system independent solution would be best if there is one, but if you have to assume an OS, assume Windows 7.

Upvotes: 1

Views: 584

Answers (1)

user149341
user149341

Reputation:

Enumerate the attached USB devices and look for a keyboard. If you find one, and it's got a vendor id of 0x05AC (Apple Inc), then it's definitely an Apple keyboard. If the vendor is something else, or if you don't find any USB keyboards (e.g, the keyboard is probably hooked up via PS2), then it's probably not an Apple keyboard.

Upvotes: 8

Related Questions