keybd_event KEYEVENTF_EXTENDEDKEY explanation required

前端 未结 3 1229
清酒与你
清酒与你 2021-01-11 20:23

In documentation it says:

KEYEVENTF_EXTENDEDKEY (0x0001): If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).

3条回答
  •  感情败类
    2021-01-11 20:53

    It is an ancient implementation detail of keyboard layouts on the original IBM PC. This is what the keyboard looked like back in 1981:

    enter image description here

    Doesn't look much like keyboards look like today. This evolved, extra keys were added like the dedicated cursor keys and the Ctrl and Alt keys to the right of the space bar. To keep it compatible with existing software that directly reads the keyboard (a very common crime back in those days), the keyboard controller reports those extended keys with the same scan code but an extra special byte ahead of it. So the right-side Ctrl and Alt keys worked the same way the left ones did, if a program cares about the distinction then it could detect the difference from the prefix byte. 0xE0 is that prefix.

    Many programs don't care which particular key you pressed, they just use the virtual key code and don't care of if it is an extended key. Just like those old MS-Dos programs didn't. Which is why you don't see a difference. And since you didn't specify the scan code, it can't make a difference. A detailed document from Microsoft that describes keyboard scan codes is available here.

提交回复
热议问题