title: How to create a walking animation in LOVE 2D
body: <p>So I was wondering how to change an image of character I've created depending on the key I've pressed/am pressing?</p>
  
  <p>My ultimate going to to have a walking animation occuring when "d" (or any of the wasd keys) is pressed but then he stands still when the "d" key has just been pressed etc. All images have been created already.</p>
  
  <p>I've tried this but it didn't work out:</p>
  
  <pre><code>function love.load()
  
      if love.keyboard.isDown("a") then
          hero = love.graphics.newImage("/hero/11.png")
      elseif love.keyboard.isDown("d") then
          hero = love.graphics.newImage("/hero/5.png")
      elseif love.keyboard.isDown("s") then
          hero = love.graphics.newImage("/hero/fstand.png")
      elseif love.keyboard.isDown("w") then
          hero = love.graphics.newImage("/hero/1.png")
      end
  
  function love.draw()
  
      love.graphics.draw(background)
      love.graphics.draw(hero, x, y)
  
  end
  </code></pre>