SDL (And Others) Virtual Key Input

Posted by David C on Stack Overflow See other posts from Stack Overflow or by David C
Published on 2012-10-09T21:33:41Z Indexed on 2012/10/10 21:37 UTC
Read the original article Hit count: 214

Filed under:
|
|

Today I set up the input in my application for all the different keys. This works fine except for virtual keys, for example, caret or ampersand. Keys that normally need shift to be got at. Using SDL these virtual keys don't work. As in they do not register an event.

if (event.type == SDL_KEYDOWN) {
        switch (event.key.keysym.sym) {
            case SDLK_CARET:
                Keys[KeyCodes::Caret] = KeyState::Down;
                break;
            case SDLK_UP:
                Keys[KeyCodes::Up] = KeyState::Down;
                break;
            default:
                break;
        }

I am absolutely sure my system works with physical keys like Up. The program queries a keystate like so:

if (Keys[KeyCode] == KeyState::Down) {
    lua_pushboolean(L, true);
} else {
    lua_pushboolean(L, false);
}

KeyCode is passed in as an argument.

So why are virtual keys, or keys that need shift to get at not working using SDL's KeyDown event type? Is more code needed to get to them? Or am I being stupid?

© Stack Overflow or respective owner

Related posts about c++

Related posts about events