as you already use CP5 try
/**
* ControlP5 Textfield
*
* by Andreas Schlegel, 2012
* www.sojamo.de/libraries/controlp5
*
*/
import controlP5.*;
ControlP5 cp5;
String textValue = "#123456";
void setup() {
size(200,200);
cp5 = new ControlP5(this);
cp5.addTextfield("input")
.setPosition(20,100)
.setSize(100,20)
.setValue(textValue)
.setFocus(true)
.setAutoClear(false)
.setColor(color(255))
;
}
void draw() {
background(200,200,0);
}
public void input(String theText) { // automatically receives at ENTER results from controller input
println("a textfield event for controller 'input' : "+theText);
}