See the question and my original answer on StackOverflow

The problem is the button "steals the focus" when we click on it, so the window doesn't receive WM_KEYDOWN messages any more. This is by design. See also this on SO: C++ Window losing focus when child button is pressed

There are multiple way to fix it, but in this case the easier is to add a SetFocus call, right after the button has been clicked, like this:

case WM_COMMAND: {
        switch (LOWORD(w_param)) {
        case BN_CLICKED: {
            SetFocus(m_hwnd_); // add this here to give focus back to window
        return 0;