Difference between revisions of "love.keyboard.isScancodeDown"

m
(Returns)
Line 14: Line 14:
 
=== Returns ===
 
=== Returns ===
 
{{param|boolean|down|True if any supplied Scancode is down, false if not.}}
 
{{param|boolean|down|True if any supplied Scancode is down, false if not.}}
 +
 +
=== Example ===
 +
Standard WASD or arrow keys movement:
 +
<source lang="lua">
 +
function love.update (dt)
 +
local up =    love.keyboard.isScancodeDown('w', 'up')
 +
local down =  love.keyboard.isScancodeDown('s', 'down')
 +
local right = love.keyboard.isScancodeDown('d', 'right')
 +
local left =  love.keyboard.isScancodeDown('a', 'left')
 +
end
 +
</source>
  
 
== See Also ==
 
== See Also ==

Revision as of 14:12, 29 January 2022

Available since LÖVE 0.10.0
This function is not supported in earlier versions.

Checks whether the specified Scancodes are pressed. Not to be confused with love.keypressed or love.keyreleased.

Unlike regular KeyConstants, Scancodes are keyboard layout-independent. The scancode "w" is used if the key in the same place as the "w" key on an American keyboard is pressed, no matter what the key is labelled or what the user's operating system settings are.

Function

Synopsis

down = love.keyboard.isScancodeDown( scancode, ... )

Arguments

Scancode scancode
A Scancode to check.
Scancode ...
Additional Scancodes to check.

Returns

boolean down
True if any supplied Scancode is down, false if not.

Example

Standard WASD or arrow keys movement:

function love.update (dt)
	local up =    love.keyboard.isScancodeDown('w', 'up')
	local down =  love.keyboard.isScancodeDown('s', 'down')
	local right = love.keyboard.isScancodeDown('d', 'right')
	local left =  love.keyboard.isScancodeDown('a', 'left')
end

See Also

Other Languages