-2

Does the love.keyreleased(key) function the same as love.keyboard.isDown?

For example, can I declare:

function love.update()

    if love.keyreleased("left") then
            hero = heroLeft
    end
end     
Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Switchkick
  • 2,716
  • 6
  • 21
  • 28
  • 3
    -1: for lack of research effort. I have no knowledge or expertise in Love2D, but I found the answer by Googling "love2d keyreleased", which took me [right to the docs.](https://love2d.org/wiki/love.keyreleased) – Nicol Bolas Feb 21 '12 at 02:47

2 Answers2

6

love.keyreleased is a callback function. It's not a function you are supposed to call. It's a function you register with the system that takes a key. The system will call it whenever a key is released.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
0

No, they're not the same function.

love.keyreleased (key) is a callback function that will be called by the application whenever a key is released, therefore you may overwrite it in order to create some kind of response to the release. You are NOT supposed to call this function. Love application will deal with that for you.

love.keyboard.isDown is a love function that returns a boolean (if the key is down - true or false). You should NOT overwrite it, otherwise you won't be able to know if a key is actually down. This function can be called inside your code.

ericariello
  • 111
  • 1
  • 11