In documentation it says:
KEYEVENTF_EXTENDEDKEY (0x0001): If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).
The simple (and incomplete) explanation is that KEYEVENTF_EXTENDEDKEY means "this keystroke is from the numeric keypad"
Since most programs behave the same if you hit '1' above the 'q' key as they do when you hit '1' on the numeric keypad (which is an extended key) - you wouldn't normally expect to see any difference when you set this flag when simulating keyboard input.
Programs that pay attention to the location of a key will usually respond to this flag.
The bScan value is a raw hardware scancode. For an explanation of scancodes look here http://en.wikipedia.org/wiki/Scancode. Like the Extended key flag, most programs pay no attention to scancodes. The values are there in case the program wants to treat the keyboard as a bunch of buttons.
It is an ancient implementation detail of keyboard layouts on the original IBM PC. This is what the keyboard looked like back in 1981:
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.
Both answers here are wrong. I don't understand why people vote for wrong answers ??
Both answers suggest that the flag is irrelevant. This is completely wrong. And the flag has NOTHING to do with the keypad.
The correct answer is that there are only scan codes from 01 to 7F but Virtual keys range from 01 to FF.
So as keyboards grew it became necessary that some scan codes have double assignment. For example on my keyboard the scan code 0x45 is assigned to the NumLock key AND to the Pause key.
To distinguish them the keyborard sends the Extended Key flag for the NumLock key but not for the Pause key.
There are several other keys that have double assignment like for example all media keys.
Run Spy++ that comes with the Visual Studio Tools and filter only WM_KEYDOWN and enable "Decoded message parameters" then hit some keys in a text editor.
Spy++ will show you for which keys the flag is set and for which keys it is not set.
Here the output from Spy++:
P WM_KEYDOWN nVirtKey:VK_NUMLOCK cRepeat:1 ScanCode:45 fExtended:1 fAltDown:0 fRepeat:0 fUp:0
P WM_KEYDOWN nVirtKey:VK_PAUSE cRepeat:1 ScanCode:45 fExtended:0 fAltDown:0 fRepeat:0 fUp:0
Another example is the scan code 2E which is assigned to the letter "C" and to VK_VOLUME_DOWN on my keyboard.
You must program it exactly the same way, otherwise keyboard injection with keybd_event()
will fail because another key is hit than the one you intended.
Do NOT trust in MapVirtualKeyEx(MAPVK_VK_TO_VSC_EX)
(>= Vista) because it does not return the extended flag for some keys although they are extended keys, like VK_LEFT for example. Another bug in this function is that it returns the extended flag (E1) for the VK_PAUSE key although this key is not extended.