How to change the play rate during the animation is being played

I wondering if it it possible to change the animation play rate during playing?
For example, in my project, I want to let user control the animation with moving mouse on X axis. If mouse is moving left, the animation should be played backward. Vice versa.