Could you not just restrict the length by not adding to the string if it's too long? Or were you after something else?
function love.keypressed(key, unicode)
if key == "backspace" or key == "delete" then
player = string.sub(player, 1, #player-1)
elseif unicode > 31 and unicode < 127 and #player <=10 then
player = player .. string.char(unicode)
end
end