[SDL] esc detector wont run -- 'out of scope'

Jonathan Dearborn grimfang4 at gmail.com
Fri Mar 24 14:25:54 PDT 2017


Checking scancodes is a different thing than handling events.  Unless
necessary to achieve an effect (e.g. holding a key while moving the mouse),
you should only be using the event structure when in the SDL_PollEvent loop.

Jonny D

On Fri, Mar 24, 2017 at 4:57 PM, speartip <clangray at fastmail.com> wrote:

> Thanks every one. In addition to having a window in context I added this
> small code:
>
>
>
>
> Code:
>
>
>  const Uint8 *keys = SDL_GetKeyboardState(NULL);
>         SDL_Event e;
> .
> .
> .
>
>  while (SDL_PollEvent(&e)){
>                     if (e.type == SDL_QUIT){
>                         done = SDL_TRUE;
>                     }
>                     if (keys[SDL_SCANCODE_ESCAPE]){
>                         done = SDL_TRUE;}
>                     }
>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20170324/997ce12f/attachment-0001.htm>


More information about the SDL mailing list