Difference between revisions of "love.keypressed"

(Add an example)
Line 10: Line 10:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
== Examples ==
 +
Exit the game when the player presses the Escape key.
 +
<source lang="lua">
 +
function love.keypressed(key, unicode)
 +
  if key == "escape" then
 +
      love.event.push('q')
 +
  end
 +
end
 +
</source>
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]

Revision as of 20:30, 26 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.

function love.keypressed(key, unicode)
   if key == "escape" then
      love.event.push('q')
   end
end

See Also


Other Languages