Author Topic: How to send Windows Key (LeftWin and RightWin) with a HID Keyboard  (Read 22559 times)

Dobaz

  • Member
  • ***
  • Posts: 23
Hi,

I have a device that emulates a hid keyboard. I can't make it send the windows key (left or right).

For the left windows key (LeftWin), I read on MSDN that the key code is 0x5B. It doesn't work. I also read from USB org that the code is 0xE3. It doesn't work. I also read that we need two bytes to send this key code 0xE05B. I can't make it work.

How to send this key to the computer?

Thanks a lot
« Last Edit: May 14, 2013, 10:42:48 pm by Dobaz »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to send Windows Key (LeftWin and RightWin) with a HID Keyboard
« Reply #1 on: May 14, 2013, 11:31:14 pm »
The HID Usage Tables doc says Usage Page 07 and Usage IDs E3 and E7.

http://www.usb.org/developers/hidpage/

grantb5

  • Member
  • ***
  • Posts: 34
Re: How to send Windows Key (LeftWin and RightWin) with a HID Keyboard
« Reply #2 on: May 15, 2013, 06:03:25 pm »
You can do the Win keys (also known as GUI keys) in two ways, both of which are "normal" keys (versus multimedia/consumer control keys).

One is to report them as up/down using bits in the modifier byte of the key report, the other is to send the codes like regular keys. In the latter case it's 0xE3 or 0xE7. Both methods seem to be widely supported. If you are using them as modifiers you need to keep them down while you add in the second key.  Also make sure your HID report is standard enough to support those codes (that is don't set you max value lower than E3). 

So the process for a modifier would be to report the Win key code. Then report the Win key code plus whatever it's modifying (like Win+A for instance). Then report the Win code. Then report all zeroes. If you just want the Win key by itself just skip the report with the A key.

0xE05B is wrong, that sounds like a PS/2 code.

GB

Bret

  • Frequent Contributor
  • ****
  • Posts: 68
Re: How to send Windows Key (LeftWin and RightWin) with a HID Keyboard
« Reply #3 on: May 15, 2013, 07:47:16 pm »
Both methods seem to be widely supported.

All the keyboards I've seen (which admittedly is not very many) report the modifier keys as a bit-map, not as "regular" keys.  I think the modifier keys are grouped together (E0-E7) for this specific reason.

Dobaz

  • Member
  • ***
  • Posts: 23
Re: How to send Windows Key (LeftWin and RightWin) with a HID Keyboard
« Reply #4 on: May 15, 2013, 10:04:03 pm »
Thanks to all of you.

I made it a modifier and it works now. I didn't think it could be treated as a modifier.

Thanks again.