Making smooth keyboard movements in Panda3D

Hi all,

I’m trying to use keyboard as an alternative to the mouse to move my keyboard so it moved smoothly. Well, not only smooth, but also comparably fast to a mouse movement

At the moment, my Pong game moved the mouse in a “jumpy” manner, as if it’s lagging. here’s my keyboard code

    self.accept('w', self.moveSecondBatUp)
    self.accept('w-up', self.moveSecondBatUp)
    self.accept('s', self.moveSecondBatDown)
    self.accept('s-up', self.moveSecondBatDown)
    self.accept('s-down', self.moveSecondBatDown)

and here’s my moveSecondBatUp code

  def moveSecondBatUp(self):
    z = self.bat2.getZ() + 2
    maxZ = self.height - 1 - self.batSize
    if (z > maxZ): z = maxZ
  def moveSecondBatDown(self):
    z = self.bat2.getZ() - 2
    minZ = 1.0;
    if (z < minZ): z = minZ


Anyone have any suggestion?
Thanks in advance,


Not to toot my own horn, but if you look at a thread called “Mouse Oddities”, you will find code that I wrote to replace the mouse with keyboard control. It was causing crashes on my system due to a driver issue, but seems to work well (and smoothly) for everyone else.

You might try that.


I just posted a keybindings example in the Code Snipplets Forum. It should be easy to modify to do what you need.

If you haven’t already, you should read the manual page I wrote: V.U.1 Keyboard Support

The last time I checked there is no such event: “w-down” the w down event is just “w” and it repeats with the keyboard autoreapeat. The autorepeat might explain the “jumpy manner”.

The “w” was just an example. The same goes for the other keys. I explained this all in the manual.