Keyboard Input Problems

My game involves input from a keyboard using WASD. When W and D are pressed, the camera should move up and to the right. When I hold both buttons down and release them at the same time, the camera continues to move in one of the directions pressed.

It seems that rather than triggering both events for the W key being released and the D key being released, only one event is triggered since they both happen at practically the same time.

Is there a way in panda3d to handle keyboard input in a non event driven way? For example, can I just check if a certain key on the keyboard is pressed? If not, do you have any other suggestions as to how I should handle this problem?



in Azure we’re using dicts and lists for all controls stuff.
Here’s our code so far:
in and modules/ you’ll find what you’re looking for.

The whole code still is really dirty and under heavy development, but the controls part works pretty well already.


I myself prefer not to do it the Roaming Ralph way (store the keymap in a dict) but do it the ButtonHandle way, since it eliminates the alt+tab issue, and for other reasons. It’s just easier and requires less code.

could you explain that a bit, pro?

I have tried doing my keyboard input using base.mouseWatcherNode and I still run into the same problem. If I release two buttons at pretty much the same time, one of the keys is always recognized as being pressed until I press the button again and release it.

Is there anything similar to isButtonUp in base.mouseWatcherNode? I mean the way to catch when a button is released?

Uhm, thats just a matter of prepending "not "?
If a button isn’t down, it’s up :slight_smile:

I mean how to catch the frame when a key was released…

PS: For future searches, I believe it is good to link to another thread here:

That’s not what this does, that’s what events are for. This is to see whether a key is pressed or not (polling).
The code you pointed to is kinda a slower and longer way to achieve the same thing.

In that thread below the main snippet from mindstormss there is another one from ynjh_jo, that does polling in the way you describe. With little error though (probably, because of some recent change in Panda code): delete key is now simply “delete”.