Skip to content

Instantly share code, notes, and snippets.

@hamzamu
Forked from biomood/Love2D_KeyTest.lua
Created June 6, 2018 09:27
Show Gist options
  • Save hamzamu/778ac0d1f326b1d7ee80bbb4c6c4d7f6 to your computer and use it in GitHub Desktop.
Save hamzamu/778ac0d1f326b1d7ee80bbb4c6c4d7f6 to your computer and use it in GitHub Desktop.
Love2D code for seeing what key/joystick button is pressed
game = {}
game.button= ""
game.key = ""
function love.load()
success = love.graphics.setMode(320, 240, false, 0)
end
function love.update(dt)
end
function love.draw()
love.graphics.clear()
love.graphics.printf(game.button, 0, 0, 50, "left")
love.graphics.printf(game.key, 0, 50, 50, "left")
end
function love.joystickreleased(joystick, button)
game.button = button
end
function love.keyreleased(key)
game.key = key
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment