Fixed keyboard.isKeyDown for chars (strings), making use of the utf8 lib when available (Lua 5.3). Closes #1214.

Thanks to @bawr for pointing out the bug in the first place.
This commit is contained in:
Florian Nücke 2015-06-14 13:53:11 +02:00
parent d37e42258e
commit b0dc3a2d84

View File

@ -159,7 +159,7 @@ end
function keyboard.isKeyDown(charOrCode)
checkArg(1, charOrCode, "string", "number")
if type(charOrCode) == "string" then
return keyboard.pressedChars[charOrCode]
return keyboard.pressedChars[utf8 and utf8.codepoint(charOrCode) or charOrCode:byte()]
elseif type(charOrCode) == "number" then
return keyboard.pressedCodes[charOrCode]
end