I am trying to say that what the return key is pressed, set the variable to whatever is typed into the keyboard.
I would also like for the writing to show up on the screen as the user types it, and I don’t know how.
I know his can be done because I’ve seen it before, but I would like some help if possible. Thanks : )
@Prynok So sorry, after looking at the code I figured out what I needed to do. However, when I run this, I get an error telling me the string value is nil. Why isn’t it what I’m typing? Even if I try to define it as a variable, it still comes back with a nil value. Any advice?
function setup()
text = ""
end
function draw()
background(255,143,255)
text(text, WIDTH/2,HEIGHT/2)
end
function keyboard(k)
if k == RETURN then
text = keyboardBuffer()
end
end
@MistReaper If you want to show what’s being typed, try this code.
function setup()
showKeyboard()
clr=false
str=""
str1=""
end
function draw()
background(40,40,50)
fill(255)
if clr then -- clear keyboard buffer
hideKeyboard()
showKeyboard()
clr=false
end
str=keyboardBuffer()
if str ~= "" then
text(str,100,500) -- show keyed input
else
text(str1,100,500) -- show input after return pressed
end
end
function keyboard(k)
if k==RETURN then
str1=keyboardBuffer()
clr=true
output.clear()
print(str1)
end
end