WASD to trigger the animation Hurt my head trying to code this until I realized how simple it was :/ 10 hours of my life I'm not getting back. Fun Fact: the way the pixel art is done, the leg movements are reversible. Meaning if you position your mouse up and press the S key it will look like it's walking backward.
Heavy inspiration from Hotline Miami it's a great game and I strongly urge you to check it out, (If you're age is 13+)