Output / input

So I am partially new to coding and my brother who is older than me codes on python, and he can use output and have the user type in the output and if it equals something he make it do something… Anyways… I was wondering if codea offers someway of having a user be able to get to a keyboard and type something. Thanks for the help!

sorry, this isn’t very clear. Can you try to explain it again?

Is this something like what you’re asking. There isn’t an input command, you have to use the keyboard function.


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

^yes thank you

^^but wait how would I make it so if I input something it does something?:
If data==“hello” then
Text(“hello”,WIDTH/2,HEIGHT 700)

@Wallisch_pls You had the code right, you just needed to put it someplace. See below. Just type hello.


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)
    
    if data=="hello" then 
        text("hello",WIDTH/2,HEIGHT-50)
    end
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

Small rewrite to the keyboard function to add backspace support:

function keyboard(key)
    if key == BACKSPACE then
        data = string.sub(data, 1, string.len(data) - 1)
    elseif key == RETURN then
        hideKeyboard()
        data = str
        if data == "" or data == nil then
            data = 0
        end
    end
end

@SkyTheCoder The backspace key works in my original program the way it’s coded now.