program a animation for bge

how can i play a animation through code instead of logic bricks

You can use KX_GameObject.playAction().

iknow its action but how can i set it up for the code its self is what iam asking

I would think something like

if keyboard event == True:
      playAction(animationname etc, etc...from below)

playAction name, start_frame, end_frame, layer=0, priority=0, blendin=0, play_mode=ACT_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0

maybe have to use: not sure on this

if keyboard event == True:
      logic.playAction(animationname etc, etc...from below)

well i know there is a way to do it with out a key input