How to stop animation if no key is pressed?

How to stop animation if no key is pressed?

This should do what you request:

if(Input.anyKey == false)
{
animation.Stop();
}