jmasterx
jmasterx

Reputation: 54173

Use arrow keys c++?

I'm new to c++ and I'm not sure how WM_KEYDOWN works. I want to have a case for each arrow key (UP,DOWN,LEFT,RIGHT)

Thanks

Upvotes: 1

Views: 2552

Answers (1)

Alex Gyoshev
Alex Gyoshev

Reputation: 11977

As noted in the WM_KEYDOWN documentation, the wParam of the message loop contains the virtual code key - therefore, you can use the following:

case WM_KEYDOWN:
    switch (wParam) {
        case VK_UP:
            // up was pressed
        break;

        case VK_DOWN:
            // down was pressed
        break;

        // etc.
    }
break;

The whole reference on virtual key codes can be found on MSDN.

Upvotes: 7

Related Questions