I've been playing A LOT with animation recently, and have pretty much sussed most of the problems. Things to bear in mind to solve your problem:
-As indi said, you need to trap the keypress somewhere.
-If you're playing the animation with
PLAY OBJECT, you must only do this once. If you run the same command every loop, you'll keep setting the animation back to the first frame, and it'll look like its static.
-If you are using the
LOOP OBJECT command, you can call this command every program loop and DB will still animate the object. I have no clue why. Inconsistent weirdness, I guess.
Something like this would work for you.
do
`Key state 20 is the t key
if keystate(20)
`Check to make sure the object is not already animating and then play the animation
if not object playing(objectnumber)
play object objectnumber,startframe,endframe
endif
endif
sync
loop
There are a plethora of niggles with the object animation, but it does work, so long as you know what to tinker with, so if you have any more problems, throw up a post and if I see it I'll try and help.
EDIT: Don't use inkey() btw. Use keystate() to avoid only being able to press one key at a time. Use the scancode() command to find out the numeric value for a specific key, then use the keystate() command to check if that key is being pressed.