title: SDL remembers last instance"s user input
body: <p>I am working on an SDL project in C and I am having trouble with the input handling.</p>
  <p>whenever I start my SDL app it remembers the last app's inputted keys and SDL_PollEvent always gives repeatedly the last key that was pressed in the previous instance of the program.</p>
  <p>btw I am compiling the code in a WSL window I have tried the same piece of code in a visual studio environment and it worked perfectly fine. So can someone explain what's happening?</p>
  <p>Here is the sample code:</p>
  <pre><code>#include &lt;SDL2/SDL.h&gt;
  #include &lt;stdio.h&gt;
  
  int main() {
      SDL_Event event;
  
      SDL_Window* sdlwind;
      if(SDL_Init(SDL_INIT_VIDEO) != 0) {
          fprintf(stderr, &quot;SDL_Init Error : %s&quot;, SDL_GetError());
          return 1;
      }
      sdlwind = SDL_CreateWindow(&quot;Engine&quot;, 0, 0, 1080, 840, SDL_WINDOW_SHOWN);
  
      if(!sdlwind) {
          fprintf(stderr, &quot;SDL_CreateWindow Error : %s&quot;, SDL_GetError());
          return 1;
      }
  
      printf(&quot;Start&quot;);
      while (1)
      {
          while (SDL_PollEvent(&amp;event))
          {
              printf(&quot;%c\n&quot;, event.key.keysym.sym);
          }
  
          if(event.key.keysym.sym == SDLK_a) {
              break;
          }
      }
      
      SDL_DestroyWindow(sdlwind);
      SDL_Quit();
      
      return 0;
  }
  </code></pre>
  <p>This sample code has outputted the first time:</p>
  <pre class="lang-none prettyprint-override"><code>OUTPUT
  ,
  ,
  ,
  ,
  ,
  ,
  // etc since the last key pressed in the previous instance was , and after terminating the program by pressing a
  // the next output becomes
  OUTPUT
  a
  a
  a
  a
  a
  // etc
  </code></pre>
  <p>I have tried removing the executable and launching another SDL program but the same problem persists. I have later tried to take input normally with <code>getchar()</code> but it didn't register any key so I am not sure but it might not be a problem related to the stdin it must be smthng with SDL and WSL.</p>