Difference between revisions of "love.keyboard.setKeyRepeat"

m (updated for 0.8.0 (setKeyRepeat is in seconds now))
m (Added oldin)
Line 1: Line 1:
 +
{{oldin|[[0.9.0]]|090|type=function}}
 
Enables key repeating and sets the delay and interval.
 
Enables key repeating and sets the delay and interval.
 
== Function ==
 
== Function ==

Revision as of 21:53, 25 August 2013

Removed in LÖVE 0.9.0
This function is not supported in that and later versions.

Enables key repeating and sets the delay and interval.

Function

Synopsis

love.keyboard.setKeyRepeat( delay, interval )

Arguments

number delay
The amount of time before repeating the key (in seconds). 0 disables key repeat.
number interval
The amount of time between repeats (in seconds)

Returns

Nothing.

Examples

Hold key to continue moving left or right

Please note that a generally better way to move an object would be to put code in love.update() which uses love.keyboard.isDown. This is just an example.

function love.load()
	x = 400
	love.keyboard.setKeyRepeat(0.01, 0.2)
end

function love.keypressed(key)
	if key == "left" then x = x - 20
	elseif key == "right" then x = x + 20
	end
end

function love.draw()
	love.graphics.circle("fill", x,300, 30,30)
end

See Also


Other Languages