However, it seems the only function in LOVE that gives me this information is love.keypressed/love.keyreleased, and I do not want to go overriding that inside some library/snippet, nor do I want to force someone to put in some random line of code in their love.keypressed function in order for me to see it.
Is there any current way of doing what I am asking? Here is a bit of pseudocode for perhaps a better explanation:
Code: Select all
local keys = {
up = "up",
down = "down",
left = "left",
right = "right",
jump = " ",
}
local function catchKey()
while true do
return KEYPRESSED -- The KeyConstant that is currently being pressed
end
end
function remapKeys(keys)
local temp = deepcopy(keys) -- Deep copy of the keys table
-- so it doesn't get mapped until
-- the end.
for k,v in pairs(temp) do
print(string.format("Please press a key to remap %s!", k))
local catch = catchKey()
if catch == "escape" then
return keys
else
v = catch
end
end
return temp
end