What is Win32 virtual key code 0xFF used for and is it documented somewhere?
I have a netbook which supports multi-touch gestures on its touchpad. When you do a three-finger swipe to the left or right, it will send some messages to the active window – for some windows this means sending page up/down keypresses.
The actua开发者_运维技巧l messages that get sent for a swipe right are, according to Spy++:
- WM_KEYDOWN, virtual key = 0xFF
- WM_KEYDOWN, virtual key = VK_NEXT
- WM_KEYUP, virtual key = VK_NEXT
- WM_KEYUP, virtual key = 0xFF
My question is: what is this 0xFF virtual key code, and is it documented somewhere? There's no corresponding #define for it in winuser.h.
0xFF
is the value used within keyboard layout code to mean "no mapping". This is how it is defined in kbd.h
of the Windows DDK/SDK:
#define VK__none_ 0xFF
Each scan code which has no assigned meaning is mapped to this virtual key code via macros. For example, scan code 0 has no mapping:
#define T00 _EQ( _none_ )
If a Fn key produces 0xFF, it is because the scan code of the Fn key has no mapping, not because 0xFF means the Fn key. There is no standard scan code for Fn keys; it is up to the manufacturer, and therefore unlikely to be mapped to anything meaningful in a standard keyboard layout.
As for why VK 0xFF would be sent: it probably isn't. Manufacturer-specific keys and buttons sometimes send (from hardware) a scan code which is not mapped to anything, but can be detected by scan code. When the manufacturer's software detects the key, it takes some action, such as sending VK_NEXT (but perhaps the action depends on settings or which application has focus). The focused application sees the keypress as well, but typically does nothing because there was no mapping for that scan code (wParam was 0xFF).
You can find the scan code in bits 16-23 of the lParam of the WM_KEYDOWN message.
On most laptops, VK 0xff corresponds to the "Fn" key.
精彩评论