Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 132419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:15:35+00:00 2026-05-11T06:15:35+00:00

I am developing a simple game in PyGame … A rocket ship flying around

  • 0

I am developing a simple game in PyGame… A rocket ship flying around and shooting stuff.


Question: Why does pygame stop emitting keyboard events when too may keys are pressed at once?

About the Key Handling: The program has a number of variables like KEYSTATE_FIRE, KEYSTATE_TURNLEFT, etc…

  1. When a KEYDOWN event is handled, it sets the corresponding KEYSTATE_* variable to True.
  2. When a KEYUP event is handled, it sets the same variable to False.

The problem: If UP-ARROW and LEFT-ARROW are being pressed at the same time, pygame DOES NOT emit a KEYDOWN event when SPACE is pressed. This behavior varies depending on the keys. When pressing letters, it seems that I can hold about 5 of them before pygame stops emitting KEYDOWN events for additional keys.

Verification: In my main loop, I simply printed each event received to verify the above behavior.

The code: For reference, here is the (crude) way of handling key events at this point:

while GAME_RUNNING:     FRAME_NUMBER += 1     CLOCK.tick(FRAME_PER_SECOND)      #----------------------------------------------------------------------     # Check for events     for event in pygame.event.get():         print event          if event.type == pygame.QUIT:             raise SystemExit()          elif event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_UP:             KEYSTATE_FORWARD = True         elif event.type == pygame.KEYUP and event.dict['key'] == pygame.K_UP:             KEYSTATE_FORWARD = False          elif event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_DOWN:             KEYSTATE_BACKWARD = True         elif event.type == pygame.KEYUP and event.dict['key'] == pygame.K_DOWN:             KEYSTATE_BACKWARD = False          elif event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_LEFT:             KEYSTATE_TURNLEFT = True         elif event.type == pygame.KEYUP and event.dict['key'] == pygame.K_LEFT:             KEYSTATE_TURNLEFT = False          elif event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_RIGHT:             KEYSTATE_TURNRIGHT = True         elif event.type == pygame.KEYUP and event.dict['key'] == pygame.K_RIGHT:             KEYSTATE_TURNRIGHT = False          elif event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_SPACE:             KEYSTATE_FIRE = True         elif event.type == pygame.KEYUP and event.dict['key'] == pygame.K_SPACE:             KEYSTATE_FIRE = False      # remainder of game loop here... 

For pressing this sequence:

  • a (down)
  • s (down)
  • d (down)
  • f (down)
  • g (down)
  • h (down)
  • j (down)
  • k (down)
  • a (up)
  • s (up)
  • d (up)
  • f (up)
  • g (up)
  • h (up)
  • j (up)
  • k (up)

Here is the output:

  • <Event(2-KeyDown {'scancode': 30, 'key': 97, 'unicode': u'a', 'mod': 0})>
  • <Event(2-KeyDown {'scancode': 31, 'key': 115, 'unicode': u's', 'mod': 0})>
  • <Event(2-KeyDown {'scancode': 32, 'key': 100, 'unicode': u'd', 'mod': 0})>
  • <Event(2-KeyDown {'scancode': 33, 'key': 102, 'unicode': u'f', 'mod': 0})>
  • <Event(3-KeyUp {'scancode': 30, 'key': 97, 'mod': 0})>
  • <Event(3-KeyUp {'scancode': 31, 'key': 115, 'mod': 0})>
  • <Event(3-KeyUp {'scancode': 32, 'key': 100, 'mod': 0})>
  • <Event(3-KeyUp {'scancode': 33, 'key': 102, 'mod': 0})>
  • <Event(2-KeyDown {'scancode': 36, 'key': 106, 'unicode': u'j', 'mod': 0})>
  • <Event(2-KeyDown {'scancode': 37, 'key': 107, 'unicode': u'k', 'mod': 0})>
  • <Event(3-KeyUp {'scancode': 36, 'key': 106, 'mod': 0})>
  • <Event(3-KeyUp {'scancode': 37, 'key': 107, 'mod': 0})>

Is this a common issue? Is there a workaround? If not, what is the best way to handle multiple-key control issues when using pygame?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:15:35+00:00Added an answer on May 11, 2026 at 6:15 am

    This sounds like a input problem, not a code problem – are you sure the problem isn’t the keyboard itself? Most keyboards have limitations on the number of keys that can be pressed at the same time. Often times you can’t press more than a few keys that are close together at a time.

    To test it out, just start pressing and holding letters on the keyboard and see when new letters stop appearing.

    My suggestion is to try mapping SPACE to a different key somewhere else and see what happens.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a simple platform game in Java using BlueJ. Over the next
Developing a simple game for the iPhone, what gives a better performance? Using a
I am developing a simple game on iPhone and I started with a View
I am developing a simple platform game using Java using BlueJ as the IDE.
I'm developing a simple 2D game in Java, everything works fine. To find the
I'm developing a simple 2D-game in OpenGL ES for the iPhone. My problem is
I'm currently developing a simple 2D game for Android. I have a stationary object
I am currently developing a simple Pong game for the iPhone. Currently using CGRectIntersectsRect
Can anyone recommend a good Java game engine for developing simple tile-based games? I'm
I've been developing a simple website using asp.net MVC and I'm starting to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.