How do I make an Animation only happen when a certain action happens?

Hi. I’m fairly new to Unity. I want it so whenever I push the key for my character to move it switches to a running animation. I tried searching for it but I couldn’t find anything. This is a 2D Game if it changes anything.

Get your hands dirty and start writing some code! Unity has lots of really great tutorials in the learn section that cover this exact topic.