Distinguishing Between Keyboard Keys and their Keypad Duplicat

Last reviewed: January 21, 1997
Article ID: Q96242
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.1, 3.5, 3.51, 4.0
        - Microsoft Windows 95 version 4.0
    

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 21, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.