tags:

views:

120

answers:

1

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

+7  A: 

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.

Alexander Gyoshev