Share via

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 development | Windows API - Win32
Developer technologies | C++
Developer technologies | 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.

0 comments No comments

Answer accepted by question author

Castorix31 91,871 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;

Was this answer helpful?

2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Tong Xu - MSFT 2,546 Reputation points Microsoft External Staff
    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.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.