Keyboard Input

How do you get the most recent thing someone typed in? I can’t figure out the keyboardBuffer() thing. Please help.

keyboardBuffer() returns a string, the most recently typed text.

How do you detect when a key is typed?

@EpicPotato Here is a small example for using the keyboard.


displayMode(FULLSCREEN)

function setup()
    hideKeyboard()
    str=""
    data=0
end

function draw()
    background(40,40,50)
    rectMode(CENTER)
    fill(255)
    text("tap screen for keyboard",WIDTH/2,550)
    text("input data then press RETURN",WIDTH/2,500)
    if keyboardBuffer() ~= nil then
        str=keyboardBuffer()
    end
    text("data  "..data,WIDTH/2,650)
    rect(WIDTH/2,600,200,50)
    fill(255,0,0)
    text(str,WIDTH/2,600)
end

function keyboard(k)
    if k==RETURN then
        hideKeyboard()
        data=str
        if data=="" or data==nil then
            data=0
        end
    end  
end

function touched(t)
    if t.state==BEGAN then
        showKeyboard()
    end
end