Hallucigenia95
Hallucigenia95

Reputation: 33

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?

Upvotes: 0

Views: 3089

Answers (1)

Qaz
Qaz

Reputation: 61910

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.

Upvotes: 2

Related Questions