Code: Select all
function love.keypressed(key)
string=string..key
end
Code: Select all
rshiftthe
Code: Select all
rshiftthebackspacebacksapce
The thing is, it's not done yet. Not even close. A script like this takes longer and more tedious code than usual. Not to mention how well I can screw stuff up (like misspelling "currentstring" repeatedly). So I'm going to try something out. I'm open-sourcing it. Well yeah, it's already open source, but I'm going to let everyone on the forum work on it.
So here's the idea: one of you takes my code, adds to it, posts it, lets someone else add more to it, etc. That way this library will get done faster and easier. Besides, I'm sure this script will be helpful to a lot of you.
I'll go ahead and post the code and the intended usage of the library:
___________________________________________________________________________________________________________
Code: Select all
normaltyping(currentstring,key)
key - the key to "type"
Code: Select all
function normaltyping(currentstring,key)
local bannedkey={} --keys that should never be typed
bannedkey[1]="up"
bannedkey[2]="down"
bannedkey[3]="left"
bannedkey[4]="right"
bannedkey[5]="home"
bannedkey[6]="end"
bannedkey[7]="pageup"
bannedkey[8]="pagedown"
bannedkey[9]="insert"
bannedkey[10]="clear"
bannedkey[11]="delete"
bannedkey[12]="f1"
bannedkey[13]="f2"
bannedkey[14]="f3"
bannedkey[15]="f4"
bannedkey[16]="f5"
bannedkey[17]="f6"
bannedkey[18]="f7"
bannedkey[19]="f8"
bannedkey[20]="f9"
bannedkey[21]="f10"
bannedkey[22]="f11"
bannedkey[23]="f12"
bannedkey[24]="f13"
bannedkey[25]="f14"
bannedkey[26]="f15"
bannedkey[27]="numlock"
bannedkey[28]="capslock"
bannedkey[29]="scrollock"
bannedkey[30]="rshift"
bannedkey[31]="lshift"
bannedkey[32]="rctrl"
bannedkey[33]="lctrl"
bannedkey[34]="ralt"
bannedkey[35]="lalt"
bannedkey[36]="rmeta"
bannedkey[37]="lmeta"
bannedkey[38]="lsuper"
bannedkey[39]="rsuper"
bannedkey[40]="mode"
bannedkey[41]="compose"
bannedkey[42]="pause"
bannedkey[43]="escape"
bannedkey[44]="help"
bannedkey[45]="print"
bannedkey[46]="sysreq"
bannedkey[47]="break"
bannedkey[48]="menu"
bannedkey[49]="power"
bannedkey[50]="euro"
bannedkey[51]="undo"
local a
local stop=0
for a=1,#bannedkey do if key==bannedkey[a] then stop=1 break else stop=0 end end
if stop==0 then
if key=="backspace" then if #currentstring>1 then currentstring=string.sub(currentstring,1,#currentstring-1) else currentstring="" end end
end
return currentstring
end