Distinguishing Between Keyboard Keys and their Keypad Duplicat

ID: Q96242

3.10 3.50 3.51 4.00 | 4.00

WINDOWS NT          | WINDOWS
kbprg

The information in this article applies to:

SUMMARY

It is possible using ReadConsoleInput() or PeekConsole() to distinguish between a key on the main keyboard and it's duplicate key on the numeric keypad. The KEY_EVENT_RECORD structure in the INPUT_RECORD structure must be used to distinguish between the two keys.

MORE INFORMATION

The following example illustrates what the KEY_EVENT_RECORD structure is filled with after a keyboard ENTER key versus a numeric keypad ENTER key is pressed.

Keyboard ENTER Key

   KeyEvent.wRepeatCount     = 1
   KeyEvent.wVirtualKeyCode  = 13
   KeyEvent.wVirtualScanCode = 28
   KeyEvent.dwControlKeyState= 00000000

Numeric Keypad ENTER Key

   KeyEvent.wRepeatCount     = 1
   KeyEvent.wVirtualKeyCode  = 13
   KeyEvent.wVirtualScanCode = 28
   KeyEvent.dwControlKeyState= 00000100

In the case of the numeric keypad key, in dwControlKeyState, the ENHANCED_KEY bit is set.

KBCategory: kbprg KBSubcategory: BseCon Additional reference words: 3.10 3.50 3.51 4.00 95

Keywords          : kbConsole kbKernBase kbGrpKernBase 
Version           : 3.10 3.50 3.51 4.00 | 4.00
Platform          : NT WINDOWS

Last Reviewed: January 23, 1997