Search code examples
c++sdl-2

How to know which keys are pressed in SDL2


How would I know what keys are currently being pressed in SDL2 (not event)?


Solution

  • if (SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_???]) {/*the key is held*/}
    

    where ??? is a key name, one of those.