Any key using .isDown
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Any key using .isDown
I'm wondering how to check all keys in an efficient way using keyboard.isDown and joystick.isDown. I know these functions take multiple parameters but having to include all keys/buttons, especially the keyboard seems really awkward to me.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Any key using .isDown
It might be a better idea to use love.keypressed instead and just ignore the argument.
EDIT: or do this:
And then instead of having something like if love.keyboard.isDown(any) then, you do if nkeysdown > 0 then.
EDIT: or do this:
Code: Select all
local nkeysdown = 0
function love.keypressed(key, u)
nkeysdown = nkeysdown + 1
-- the rest of love.keypressed
end
function love.keyreleased(key, u)
nkeysdown = nkeysdown - 1
-- the rest of love.keyreleased
end
Help us help you: attach a .love.
Re: Any key using .isDown
Ah, yes that makes sense, thanks!
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot] and 7 guests