Search code examples
c++wxwidgets

wxWidgets keyboard event


I have a problem with using Key event: there is example in documentation:

void OnChar(wxKeyEvent& event, double moveSpeed)
{
wxChar uc = event.GetUnicodeKey();
if ( uc != WXK_NONE )
{
    ...
}
else // No Unicode equivalent.
{
    // It's a special key, deal with all the known ones:
    switch ( event.GetKeyCode() )
    {
        case WXK_LEFT:
        case WXK_RIGHT:
            break;
        case WXK_F1:
            break;
    }
}

but what if i have to use keyboards event in different function ? I know that in other library you can simply use:

if (keyDown(SDLK_DOWN))
{
    //code
}

but how can I use that in wxwidgets ?


Solution

  • You can use wxGetKeyStats() function if you really need to, but usually you definitely want to react to keyboard events instead of checking for the key state.