1

I'm trying to make simple background/console tool in C++ which would listen to my keystrokes. SDL_PollEvent nor SDL_GetKeyboardState listens when foreign window is focused. Question is, if it is possible to do this with SDL2 or do I need to use other multi-platform library or should I just do it from scratch per OS?

Note: Right now I want to use this tool on linux and I managed to find libX11 solution: Listening to keyboard events without consuming them in X11 - Keyboard hooking.

Tellegar
  • 81
  • 7

1 Answers1

1

I don't believe that global keystroke capture is in scope for SDL.

You'll have to use some other platform-specific means. For Linux and Unix, libX11 is one of the options, another would be to use /dev/input/event# (see e.g. here for examples).

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313