animation play on click

Hello, I am totally newbie in C# scripting ( self-learn on some basic ), so i want to play an animation on click.

Example: I have a landing gear model with 2 animation clips with it ( retract and release );

And i have created an animator with a controller ( namely wheel );

I want to script so that when i walk in front of the landing gear ( i have make a collider );

and upon pressing a key, the wheel will retract, and once i press one more time, other animation clip will be played…it will play alternatively whenever i press on same key.

p/s: What should i do to the animator controller in the animator panel in this case.
really grateful to anyone who can stop by and teach me T_T…

First, Have this Animation Documentation page.

I would just create an OnTriggerStay option and an If(input.getKey()){// Play Animation}. Note that you perhaps would need to create an Iterator Coroutine that would keep playing the animation, I think there should be something like animation.length.