You're pulling a char event, which you should not.
Do not pull an event in os.pullEvent() and then do this:
if event == "key" then
if arg == keys.backspace then
--
elseif arg == keys.enter then
table.insert(eTPassword, arg) -- Now insert it into the table after clicking enter
elseif event == "char" then
write(arg)
-- table.insert(eTPassword, arg)
-- I'd suggest to only add the password into the table after the person clicks enter.
end
Also, why are you using a for loop?
EDIT: Heres a custom function I made to maximize the amount of characters allowed in the read.
function limitRead(nLimit, replaceChar)
term.setCursorBlink(true)
local cX, cY = term.getCursorPos()
local rString = ""
if replaceChar == "" then replaceChar = nil end
repeat
local event, p1 = os.pullEvent()
if event == "char" then
-- Character event
if #rString + 1 <= nLimit then
rString = rString .. p1
write(replaceChar or p1)
end
elseif event == "key" and p1 == keys.backspace and #rString >= 1 then
-- Backspace
rString = string.sub(rString, 1, #rString-1)
xPos, yPos = term.getCursorPos()
term.setCursorPos(xPos-1, yPos)
write(" ")
term.setCursorPos(xPos-1, yPos)
end
until event == "key" and p1 == keys.enter
term.setCursorBlink(false)
print() -- Skip to the next line after clicking enter.
return rString
end
-- And you call it like this
input = limitRead(10)
-- If you want to replace it with a char, like read("*") then
password = limitRead(10, "*")