Difference between revisions of "love.keyboard.setKeyRepeat"
(Updated for 0.9.0 and added a new example) |
m (→Examples: Fixed arguments of love.keypressed (scancode parameter added)) |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | Enables or disables repeat | + | Enables or disables key repeat for [[love.keypressed]]. It is disabled by default. |
== Function == | == Function == | ||
{{newin|[[0.9.0]]|090|type=variant}} | {{newin|[[0.9.0]]|090|type=variant}} | ||
Line 7: | Line 7: | ||
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|boolean|enable|Whether repeat keypress events should be enabled when a key is held down | + | {{param|boolean|enable|Whether repeat keypress events should be enabled when a key is held down.}} |
=== Returns === | === Returns === | ||
Nothing. | Nothing. | ||
+ | === Notes === | ||
+ | The interval between repeats depends on the user's system settings. This function doesn't affect whether [[love.textinput]] is called multiple times while a key is held down. | ||
== Function == | == Function == | ||
Line 25: | Line 27: | ||
== Examples == | == Examples == | ||
− | |||
Hold left or right to change the position. | Hold left or right to change the position. | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 33: | Line 34: | ||
end | end | ||
− | function love.keypressed(key, isrepeat) | + | function love.keypressed(key, scancode, isrepeat) |
if key == "right" then | if key == "right" then | ||
x = (x + 80) % love.graphics.getWidth() | x = (x + 80) % love.graphics.getWidth() | ||
Line 42: | Line 43: | ||
function love.draw() | function love.draw() | ||
− | love.graphics.circle("fill", x, 100 | + | love.graphics.circle("fill", x, 100, 50, 50) |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
</source> | </source> | ||
Line 74: | Line 52: | ||
* [[love.keypressed]] | * [[love.keypressed]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | {{#set:Description=Enables or disables repeat | + | {{#set:Description=Enables or disables key repeat for [[love.keypressed]].}} |
{{#set:Since=000}} | {{#set:Since=000}} | ||
== Other Languages == | == Other Languages == | ||
{{i18n|love.keyboard.setKeyRepeat}} | {{i18n|love.keyboard.setKeyRepeat}} |
Latest revision as of 09:46, 16 April 2020
Enables or disables key repeat for love.keypressed. It is disabled by default.
Contents
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. This function doesn't affect whether love.textinput is called multiple times while a key is held down.
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
Hold left or right to change the position.
function love.load()
love.keyboard.setKeyRepeat(true)
x = 50
end
function love.keypressed(key, scancode, 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, 50, 50)
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info