How to get input with windows api

Some friends and I are starting to make a video game. I'm pretty new to the windows api though and to do some prototyping for our early stages I need to know how to parse input given via the windows message system. The main thing I need to do is get input from the keyboard in the form of what key is pressed. Any idea on how to parse lParam and wParam in the winProc function to find what key was pressed?

Answers


From WM_KEYDOWN, wParam The virtual-key code of the nonsystem key.

From WM_CHAR, wParam The character code of the key.

The latter is pretty straightforward, whereas the former can be referenced here: Virtual Key Codes.

Let's say you're looking for escape key presses. In the table, you can see the vk code is 0x1B, but it has an alias VK_ESCAPE:

case WM_KEYDOWN:
    if (wParam == VK_ESCAPE) {
        //handle
    }

    break;

Take your pick, depending on what kinds of keys you need to handle.


Need Your Help

How to determine if there is a valid Lync user by email using Lync SDK?

c# lync-2010 lync

Given an eMail address, I am trying to determine if it is a valid user's signin address.

CSS - Triangle/Arrow doesn't scroll with its parent container

html css css3 css-position

I am trying to have a triangle/arrow at the right of arrow-td. Initial plot with the code below works but the triangle/arrow doesn't scroll with its container arrow-td.