Difference between revisions of "love.keyboard.isDown"

m (1 revision: Importing from potato (again).)
Line 1: Line 1:
 
 
Checks whether a certain key is down.
 
Checks whether a certain key is down.
 
== Function ==
 
== Function ==
Line 10: Line 9:
 
=== Returns ===
 
=== Returns ===
 
{{param|boolean|down|True if the key is down, false if not.}}
 
{{param|boolean|down|True if the key is down, false if not.}}
 +
== Examples ==
 +
=== Quit on hitting escape ===
 +
<source lang="lua">
 +
function love.keypressed(k)
 +
if k == 'escape' then
 +
love.event.push('q') -- quit the game
 +
end
 +
end
 +
</source>
 
== See Also ==
 
== See Also ==
 
* [[parent::love.keyboard]]
 
* [[parent::love.keyboard]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Checks whether a certain key is down.}}
 
{{#set:Description=Checks whether a certain key is down.}}

Revision as of 00:02, 18 February 2010

Checks whether a certain key is down.

Function

Synopsis

down = love.keyboard.isDown( key )

Arguments

KeyConstant key
The key to check.

Returns

boolean down
True if the key is down, false if not.

Examples

Quit on hitting escape

function love.keypressed(k)
	if k == 'escape' then
		love.event.push('q') -- quit the game
	end	
end

See Also