It is not clear what you are trying to do. Please remember we have no context about your application. You need to explain what each state suppose to do. You need to also tidy up your code. For instance:
if ( key == RETURN || key == ENTER)- This is not proper:
infosOutput[] = infos[]; - Explain this
infosOutput[0]Where is this coming from? -
infosInput = cp5.addTextfield("")You need to assign a name to your text field so it is my understanding. Check the ControlP5 reference.
Finally, if you are following some guide, please share it as well as it will help understand what your goal is.
Don’t forget to update your code to show the latest version. share your latest code.
Kf