|
|
Callback
keypressed( key )
Synopsis
function keypressed( key ) ... end
Arguments
key
The key code of the pressed key.
Returns
(Nothing)
Examples
Example 53: Keyboard callbacks
-- Keypressed: Called whenever a key was pressed. function keypressed(key) -- I don't want to register spaces. if key ~= love.key_space then lastkey = key .. " pressed" end end -- Keyreleased: Called whenever a key was released. function mousereleased(key) -- I don't want to register spaces. if key ~= love.key_space then lastkey = key .. " released" end end -- Load a font and set the text variable. function load() love.graphics.setFont(love.graphics.newFont(love.default_font, 12)) lastkey = "nothing" end -- Output the last mouse button which was pressed/released. function draw() love.graphics.draw("Last key: " .. lastkey, 100, 100) end
Copyright © 2006-2008 LÖVE Development Team.
|