A bit over my head

I’m trying to make an animation (kind of a simple game, really) and I reached a point where I could really use your help.
Ok, I need a script that would play an animation consisting of 4 frames for, say 20 seconds. The order of those frames needs to be random but it has to stop after 20 seconds.
Next, frames need to change each, say, half a second.
But, as much as I MIGHT be able to figure this one out, here’s what made me post here. The four frames are four keys on a keyboard. Each time frame changes to a corresponding key drawing, one has to hit the right key on the keyboard to make a different animation on the stage, animate.
I’m sorry to ask this much of you but I’m really stuck and I honestly need help with this one.
Please post if you have any questions, I’ll answer them withing few hours top.
Thank you in advance.