Moving window sends a SDL_KEYUP on SDLK_NUMLOCK

I don’t know if this is known normal behavior, but I just encountered
this. If I do something like this:

SDL_WaitEvent( &event );
if( event.type == SDL_KEYUP )
return event.key.keysym.sym;

And then move the window instead of pressing a key, I receive a num lock
key up event when the num lock light is on. If I change it to “if(
event.type == SDL_KEYDOWN )” and I let the num lock light off, the event
doesn’t fire. The same thing happens with Capslock (for some reason I
couldn’t test with scroll lock, it wouldn’t light up).

Is there a work around for this or is this bugzilla worthy?

Thanks.

Drrak,

This isn’t a solution, but I have noticed the exact same thing, only I
don’t even have to move the window – moving the mouse outside the SDL
window is enough to trigger the key up event.

I’m wondering if maybe when the SDL window loses focus it
automatically sends a keyup to any key that was down. That way the
next application that is in focus doesn’t receive key strokes.

JohnOn 8/11/07, Drrak Koon wrote:

I don’t know if this is known normal behavior, but I just encountered
this. If I do something like this:

SDL_WaitEvent( &event );
if( event.type == SDL_KEYUP )
return event.key.keysym.sym;

And then move the window instead of pressing a key, I receive a num lock
key up event when the num lock light is on. If I change it to “if(
event.type == SDL_KEYDOWN )” and I let the num lock light off, the event
doesn’t fire. The same thing happens with Capslock (for some reason I
couldn’t test with scroll lock, it wouldn’t light up).

Is there a work around for this or is this bugzilla worthy?

Thanks.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

John,

I think your assumption is right, if you press any key with num lock off
and make the SDL window lose the focus, a KEYUP event is sent for that key.

For now, I’ll use KEYDOWN, it shouldn’t really matter for my use, but
thinking a bit about it, I guess it’s intended so that a key doesn’t get
"stuck" on a KEYDOWN event when it doesn’t have focus anymore.

Drak> Drrak,

This isn’t a solution, but I have noticed the exact same thing, only I
don’t even have to move the window – moving the mouse outside the SDL
window is enough to trigger the key up event.

I’m wondering if maybe when the SDL window loses focus it
automatically sends a keyup to any key that was down. That way the
next application that is in focus doesn’t receive key strokes.

John

On 8/11/07, Drrak Koon <@Drak_Koon> wrote:

I don’t know if this is known normal behavior, but I just encountered
this. If I do something like this:

SDL_WaitEvent( &event );
if( event.type == SDL_KEYUP )
return event.key.keysym.sym;

And then move the window instead of pressing a key, I receive a num lock
key up event when the num lock light is on. If I change it to “if(
event.type == SDL_KEYDOWN )” and I let the num lock light off, the event
doesn’t fire. The same thing happens with Capslock (for some reason I
couldn’t test with scroll lock, it wouldn’t light up).

Is there a work around for this or is this bugzilla worthy?

Thanks.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org