Handling Input
Respond to keys and mouse.
Two Ways to Read Input
LÖVE offers two input styles. Polling asks "is this key down right now?" each frame, ideal for continuous actions like movement.
Events are callbacks that fire once when something happens, like love.keypressed, ideal for one-shot actions like jumping or shooting.
Polling the Keyboard
love.keyboard.isDown(key) returns true while a key is held. Call it inside love.update for smooth, continuous response.
Because it is checked every frame, holding the key keeps the action going. This is the natural fit for moving a player around.
function love.update(dt)
if love.keyboard.isDown('right') then
player.x = player.x + player.speed * dt
end
end