Re: Declare a key press combination for love.keyboard.isDown
Posted: Mon Mar 05, 2012 11:43 pm
Let me take a stab:
Just an idea, but probably not very good as the lctrl and rctrl difference might be a problem.
EDIT: Oops, the vararg can't be captured by the closure, so that code won't work.
Use this instead, maybe:
Code: Select all
function makeKeyCombo( ... )
return function()
for i = 1, select('#', ...) do
if not love.keyboard.isDown(select(i, ...)) then return false end
end
return true
end
end
ctrld = makeKeyCombo( "lctrl", "d" )
function love.update(dt)
if ctrld() then print("Nice.") end
end
EDIT: Oops, the vararg can't be captured by the closure, so that code won't work.
Use this instead, maybe:
Code: Select all
function makeKeyCombo( ... )
local keys = {...}
return function()
for i = 1, #keys do
if not love.keyboard.isDown(keys[i]) then return false end
end
return true
end
end