Skip to main content

love.keyboard.setKeyRepeat

love.keyboard.setKeyRepeat

Enables or disables key repeat. It is disabled by default.

Function

Available since LÖVE 0.9.0
This variant is not supported in earlier versions.

Synopsis

love.keyboard.setKeyRepeat( enable )

Arguments

boolean enable
Whether repeat keypress events should be enabled when a key is held down.

Returns

Nothing.

Notes

The interval between repeats depends on the user's system settings.

Function

Removed in LÖVE 0.9.0
This variant is not supported in that and later versions.
Enables key repeating and sets the delay and interval.

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

Available since LÖVE 0.9.0
This example is not supported in earlier versions.
Hold left or right to change the position.
function love.load()
    love.keyboard.setKeyRepeat(true)
    x = 50
end

function love.keypressed(key, isrepeat)
    if key == "right" then
        x = (x + 80) % love.graphics.getWidth()
    elseif key == "left" then
        x = (x - 80) % love.graphics.getWidth()
    end
end

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

Removed in LÖVE 0.9.0
This example is not supported in that and later versions.
Hold left or right to continue moving. 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

Comments

Popular posts from this blog

Natural

Wonderful world

God gave us a world to live in, Food to put on our plates, Water to drink when we are thirsty, That flows down rivers and lakes. Animals that live on the land, Birds that fly in the sky, Fish that live in the sea, All these things that please the eye. When will we come to realise, What a beautiful world we have, We should all want good for the earth, Not destruction and all that is bad. So why do we have to fight, Bringing loss, heartbreak and tears, We live our lives each day, With uncertainties, worries and fears. Why is there so much bitterness, Let's say to ourselves it must cease, People should all come together, Then the world will at last live in peace. I see trees of green, red roses too I see them bloom, for me and you. And I think to myself... what a wonderful world. I see skies of blue, and clouds of white The bright blessed day, the dark sacred night. And I think to myself... what a wonderful world. The colors of the rainbow, so pretty i...

The Coldest Winter I Ever Spent Was a Summer in San Francisco

The Coldest Winter I Ever Spent Was a Summer in San Francisco Posted on November 30, 2011 Locale: San Francisco, California? Paris, France? Duluth, Minnesota? Milwaukee, Wisconsin? Originator: Mark Twain? Horace Walpole? James Quin? R. Q. Grant? Lord Byron? Anonymous? Dear Quote Investigator : Living in Menlo Park near San Francisco I have heard the following witticism credited to Mark Twain many times: The coldest winter I ever spent was a summer in San Francisco. The coldest winter I ever saw was the summer I spent in San Francisco. I actually enjoy the weather here, so this saying always seemed implausible to me. Also, the San Francisco Chronicle once printed an article that cast doubt on the Twain attribution. Can you figure out who created this joke? Also, was the remark originally about SF or some other locale? Quote Investigator : There is no evidence in the papers and speeches of Mark Twain that he ever made this remark about San Franc...