A typical C++ message loop looks like this
MSG msg;
while (GetMessage(&msg, null, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
The function of TranslateMessage is to generate WM_CHAR messages from WM_KEYDOWN messages, so if you want to see WM_CHAR messages you need to be sure to pass WM_KEYDOWN messages to it. If you don't care about WM_CHAR messages, you can skip that, and do something like this.
extern void OnKeyDown(WPARAM key);
extern void OnKeyUp(WPARAM key);
MSG msg;
while (GetMessage(&msg, null, 0, 0))
{
if (msg.message == WM_KEYDOWN)
OnKeyDown (msg.wParam);
else (msg.message == WM_KEYUP)
OnKeyUp(msg.wParam);
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Notice that OnKeyDown and OnKeyUp messages are defined as taking a WPARAM rather than a char. That's because the values for WM_KEYDOWN and WM_KEYUP aren't limited to values that fit in a char. See WM_KEYDOWN