When using SDL for keyboard input only certain keys seems to work (arrows, pageup\pagedown).
This is the code I am using:
const auto sdlScanCodes = {...SDL_SCANCODE_A, SDL_SCANCODE_F1, SDL_SCANCODE_SPACE, SDL_SCANCODE_LSHIFT ...etc}
SDL_PumpEvents();
const auto sdlKeyStatesPtr = SDL_GetKeyboardState(nullptr);
for(auto sdlScanCode: sdlScanCodes) {
const auto sdlKeyCode = SDL_SCANCODE_TO_KEYCODE(sdlScanCode);
const bool downKeyCode = sdlKeyStatesPtr[sdlKeyCode];
const bool downScanCode = sdlKeyStatesPtr[sdlScanCode];
}
Update: Note that downScanCode never works, and as said, downKeyCode works for some keys.
Worked when I used the keycodes directly, instead of converting scancodes