Below is a sample function I have to implement a jumping mechanic in a small platforming game.
function love.keypressed(key)
if (key == "w" or key == "up" or key == "space") and player.grounded then
player.grounded = false
player.yVelocity = player.JUMP
end
end
The function detects a keypress and based on what key it is, runs the code to let the player jump. The 'w' and 'up' keys work normally, but I try and and press space, nothing happens. I thought the problem was that I was using the wrong name to reference the space key, but according to Love2d's own documentation, it is correct. Note that none of these keys are used anywhere else in the script and so there is no interference from outside code.