Difference between revisions of "love.keypressed"

m (better comments)
m (Add more see alsos.)
Line 21: Line 21:
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]
 +
* [[love.keyreleased]]
 +
* [[love.keyboard.isDown]]
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]
 
{{#set:Description=Callback function triggered when a key is pressed.}}
 
{{#set:Description=Callback function triggered when a key is pressed.}}

Revision as of 16:03, 27 September 2011

Callback function triggered when a key is pressed.

Function

Synopsis

love.keypressed( key, unicode )

Arguments

KeyConstant key
Character of the key pressed.
number unicode
The unicode number of the key pressed.

Returns

Nothing.

Examples

Exit the game when the player presses the Escape key, using love.event.push.

function love.keypressed(key)   -- we do not need the unicode, so we can leave it out
   if key == "escape" then
      love.event.push("q")   -- actually causes the app to quit
   end
end

See Also


Other Languages