How to tell key events of num key pressing down from main key area and num key area

Rer 80 Reputation points
2023-08-24T03:58:58.63+00:00

How to tell key events of num key pressing down from main key area and num key area in Win32 application?

Exactly the top num keys and those on right-hand side. I've used WM_CHAR to get key events but it fails to distinguish them. They actually have the same key values(?). Should I use other messages to receive events?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,413 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,523 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,481 Reputation points
    2023-08-24T07:57:35.8333333+00:00

    This test works for me : (test Beep if Numpad (0-9 and +/-))

    	case WM_CHAR:
    	{
    		UINT nScanCode = LOBYTE(HIWORD(lParam));
    		if (nScanCode >= 0x47 && nScanCode <= 0x52)
    			Beep(6000, 10);
    	}
    	break;
    
    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Tong Xu - MSFT 761 Reputation points Microsoft Vendor
    2023-08-24T06:31:26.0466667+00:00

    Hi, @Rer
    Welcome to Microsoft Q&A!

    1. They don't have the same key values between main key area and num key area.
      You can see this documentation.
      The following table shows the symbolic constant names, hexadecimal values, and mouse or keyboard equivalents for the virtual-key codes used by the system. The codes are listed in numeric order.
    2. If you want to obtain the virtual key code from a WM_CHAR message,
      please refer to this thread.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments