You can also use the pre-defined flags.
Code:
bIsUp = (HIWORD(lParam) & KF_UP);
bAltIsDown = (HIWORD(lParam) & KF_ALTDOWN);
bExtended = (HIWORD(lParam) & KF_EXTENDED);
This is the list of flags:
Originally Posted by
MSDN About Keyboard Input
KF_ALTDOWN Manipulates the ALT key flag, which indicated if the ALT key is pressed.
KF_DLGMODE Manipulates the dialog mode flag, which indicates whether a dialog box is active.
KF_EXTENDED Manipulates the extended key flag.
KF_MENUMODE Manipulates the menu mode flag, which indicates whether a menu is active.
KF_REPEAT Manipulates the repeat count.
KF_UP Manipulates the transition state flag.