SDL_GetModState doesn't work arfter restoring the window

Hello,

I have an app and inside this app I’m checking the state of caps and num lock keys using SDL_GetModState() function.

The problem is the following:

  1. For example Caps lock on my OS is turned ON
  2. My app also shows that Caps lock is turned ON:
    (SDL_GetModState() & KMOD_CAPS) returns true
  3. Then I minimize the window of the app and press Caps button. Caps lock is turned OFF on my OS now
  4. After that, I restore the window of the app. App checks the state of Caps and for some reason it shows that Caps lock is turned ON (while it is turned off on my OS):
    (SDL_GetModState() & KMOD_CAPS) returns true, while it should be false

If I again minimize and restore the window (without pressing Caps now), the app starts to show correct state of Caps.

I can’t understand why SDL_GetModState() starts giving correct result only after second minimization and restoration of the window. The version of SDL I’m using is 2.0.14

Any help is appreciated.