# Keyboard Bug with SDLK\_UP and 2 others keys?

**URL:** <https://discourse.libsdl.org/t/keyboard-bug-with-sdlk-up-and-2-others-keys/7452>\
**Category:** SDL Development\
**Created:** [September 15, 2002, 5:36pm UTC](https://discourse.libsdl.org/t/keyboard-bug-with-sdlk-up-and-2-others-keys/7452 "2002-09-15T17:36:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atelier3w\_Laurent](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/ba9def/32.png) [@atelier3w\_Laurent](https://discourse.libsdl.org/u/atelier3w_Laurent)\
**Post date:** [September 15, 2002, 5:36pm UTC](https://discourse.libsdl.org/t/keyboard-bug-with-sdlk-up-and-2-others-keys/7452/1 "2002-09-15T17:36:01Z")

</div>

Hi,

I did find a problem with SDLK\_UP and OpenGL.

If you push at the same time (about 5 seconds):  
SDLK\_UP/SDLK\_RIGHT/SDLK\_LEFT, you will loose some frame, but with:  
SDLK\_DOWN/SDLK\_RIGHT/SDLK\_LEFT or others keys, this problem will not be !!  
I think SDLK\_UP is broken

I saw this problem with other games like: Demonstar, Ultimate Steroids,  
Moral Minus, etc…

I give you a part about my code:----------

keys = SDL\_GetKeyState(NULL);

if(keys[SDLK\_UP] == SDL\_PRESSED)  
{  
// move a cube  
goto left\_right; //(do not check SDLK\_DOWN if SDLK\_UP = TRUE)  
}

if(keys[SDLK\_DOWN] == SDL\_PRESSED)  
{  
// move a cube  
}

left\_right:

if(keys[SDLK\_LEFT] == SDL\_PRESSED)  
{  
// move a cube  
goto end; //(do not check SDLK\_RIGHT if SDLK\_LEFT = TRUE)  
}

if(keys[SDLK\_RIGHT] == SDL\_PRESSED)  
{  
// move a cube  
}

end:

* * *

Please tell me what can I do ?

Laurent (France)

* * *

Rejoignez MSN Hotmail, le plus important service de messagerie  
[http://www.hotmail.com/fr](http://www.hotmail.com/fr)

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [September 16, 2002, 1:49am UTC](https://discourse.libsdl.org/t/keyboard-bug-with-sdlk-up-and-2-others-keys/7452/2 "2002-09-16T01:49:01Z")

</div>

> Hi,

> I did find a problem with SDLK\_UP and OpenGL.

> If you push at the same time (about 5 seconds):  
> SDLK\_UP/SDLK\_RIGHT/SDLK\_LEFT, you will loose some frame, but with:  
> SDLK\_DOWN/SDLK\_RIGHT/SDLK\_LEFT or others keys, this problem will not be !!  
> I think SDLK\_UP is broken

It actually sounds like a limitation of your keyboard. Many keyboards  
support pressing some combinations of keys together but not other combinations.  
It may be that your keyboard is emulating multiple key press in that situation  
by spamming the operating system with keyboard interrupts, which might cause  
framerate reduction.

That’s my theory, anyway. 🙂

See ya,  
-Sam Lantinga, Software Engineer, Blizzard Entertainment

---

<div class="post-metadata">

**Author:** ![Jimmy](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/ee59a6/32.png) [@Jimmy](https://discourse.libsdl.org/u/Jimmy)\
**Post date:** [September 16, 2002, 11:53am UTC](https://discourse.libsdl.org/t/keyboard-bug-with-sdlk-up-and-2-others-keys/7452/3 "2002-09-16T11:53:01Z")

</div>

> > Hi,
> 
> > I did find a problem with SDLK\_UP and OpenGL.
> 
> > If you push at the same time (about 5 seconds):  
> > SDLK\_UP/SDLK\_RIGHT/SDLK\_LEFT, you will loose some frame, but with:  
> > SDLK\_DOWN/SDLK\_RIGHT/SDLK\_LEFT or others keys, this problem will not be !!  
> > I think SDLK\_UP is broken
> 
> It actually sounds like a limitation of your keyboard. Many keyboards  
> support pressing some combinations of keys together but not other combinations.  
> It may be that your keyboard is emulating multiple key press in that situation  
> by spamming the operating system with keyboard interrupts, which might cause  
> framerate reduction.
> 
> That’s my theory, anyway. 🙂
> 
> See ya,  
> -Sam Lantinga, Software Engineer, Blizzard Entertainment

Just my 2 cents here, but I think Sam is right. I remember exactly this  
happening back in the DOS days when I was writing a handler for the  
keyboard.

My keyboard back in the day would allow 3 keys at once, the fourth would  
‘unpress’ the first three and start repeating on the fourth, then no  
further presses would be accepted until all of the originals were  
released.On Mon, 2002-09-16 at 04:48, Sam Lantinga wrote:

> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)  
> –

End of Rant.

Jimmy  
Jimmy’s World ([http://www.jimmysworld.org](http://www.jimmysworld.org))  
-------------- next part --------------  
A non-text attachment was scrubbed…  
Name: not available  
Type: application/pgp-signature  
Size: 189 bytes  
Desc: This is a digitally signed message part  
URL: [http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020916/d8747572/attachment.pgp](http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020916/d8747572/attachment.pgp)
