if inputObj ~= nil then
if isLetter(key)==1 or isDigit(key)==1 then
if (love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift") or key=="capslock") and #(inputObj.input_string)<24 then
inputObj.input_string = inputObj.input_string .. numpadCheck( toUpper(key))
else
if #(inputObj.input_string)<24 then inputObj.input_string = inputObj.input_string .. numpadCheck(key) end
end
elseif key == "backspace" or key == "delete" then
inputObj.input_string = string.sub(inputObj.input_string, 1, #(inputObj.input_string)-1)
end
end
if key == "capslock" doesn't work, didn't expect it to, but worth a shot I guess. It says that Caps-on is a key-press, what does that mean? How do I check it?
Caps mode is OS-dependant, plus there are a few more text modes besides caps. The point is, you shouldn't care, and just take the input as it is. Then, after you're finished, you can do some text processing.
But the input has to be case-sensitive and I don't want to remove this functionality which is pretty much built in Windows from the user.
If I have to, I will check on which OS the user is (I'm planning a release for Windows and Linux only for now).
It sounds like you want to be using love.textinput instead. That automatically deals with caps lock, keyboard layouts, and even multi-key input sequences.
KayleMaster wrote: ↑Mon Apr 17, 2017 3:47 pm
I don't want any special symbols in my string so I just wrote my own that accepts A-Z, a-z, 0-9.
How would I handle that with textinput?
You accept all text input and then do string match with a pattern that only allows those characters:
You can also do this on per-character basis, if you accept one character at a time. Just make sure to make some indication that character was not accepted.
KayleMaster wrote: ↑Mon Apr 17, 2017 8:56 pm
Oh nice, didn't know about pattern matching yet.
Is the parameter of textinput a string, a key, or something else?
It's the UTF-8 encoded character that was pressed on the keyboard.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.