Accept(<event>, <Func>) help

Hi guys I’m having trouble with the Accept function and what im trying to do is make my character “Robo” do a walk cycle if the ‘w’ key is pressed.
Here is the code

#Importing Modules
import direct.directbase.DirectStart
from direct.task import Task
from direct.showbase import DirectObject
from pandac.PandaModules import KeyboardButton
from direct.actor import Actor
import math
#Load Robo
Robo = Actor.Actor("/c/Panda 3d Models/RoboVentures/Models/Robo.egg",{"walk":"/c/Panda 3d Models/RoboVentures/Models/RoboWalk.egg"})
Robo.setScale(1,1,1)
Robo.reparentTo(render)
class ReadKeys(DirectObject.DirectObject):
  def __init__(self):
    self.accept('w', self.RoboWalk)

  def Robowalk(self):
        Robo.play("walk")

run()

If anyone could help me I would very much appreciate it

#Importing Modules
import direct.directbase.DirectStart
from direct.task import Task
from direct.showbase import DirectObject
from pandac.PandaModules import KeyboardButton
from direct.actor import Actor
import math

#Load Robo
Robo = Actor.Actor("/c/Panda 3d Models/RoboVentures/Models/Robo.egg",
{“walk”:"/c/Panda 3d Models/RoboVentures/Models/RoboWalk.egg"})
Robo.setScale(1,1,1)
Robo.reparentTo(render)

class ReadKeys(DirectObject.DirectObject):
def init(self):
self.accept(‘w’, self.RoboWalk)

def Robowalk(self):
Robo.play(“walk”)

ReadKeys()
run()

Actually, since readKeys is a class, you’ll need to instantiate it. I’m not sure just calling the class name will work.

More generally, it’s very bad form to have things kicking around loose at global scope. You’ll really want to have a game class or something, extending DirectObject, to contain Robo and everything else. Then you can set up your event listeners in game.init().