CCCPaste

typewrter

-- monkey_typewriter.lua
math.randomseed(os.time())

-- characters the "monkey" can type
local chars = {}
for i = 32, 126 do  -- printable ASCII range
    table.insert(chars, string.char(i))
end

-- function to get a random character
local function random_char()
    return chars[math.random(#chars)]
end


-- main typing loop
while true do
    io.write(random_char())
    io.flush()
    -- random short delay between keystrokes
    local delay = math.random() * 0.5+0.3  -- between 0 and 0.1 seconds
    sleep(delay)
end