Input Controlled Animation

Hello! I have an animation composed of three actions:

  • Beginning of walking
  • Walking Cycle
  • Stop from walking

I want to control the period of ”Walking Cycle” with an input:
The overall animation (Walk) starts as soon as give an input (for example I press a key), and continues as long as I keep giving the input (I keep pressing the key). When I stop giving the input, the walking stops.

How could I do this, or what should I do to make this possible in the game engine (ex. Godot)?