How to give suggestions in input box?

I have created an input box where a user can type and I do things later on with what they type in. I was wondering if there was any way in p5.js to put grey text in the input box to “suggest” what the user is to type in, like your first, last name and so on, which should also disappear when they start typing.

1 Like

it is not what you asked for, but might be usable:

var question = 'your name?';

function setup() {
  createCanvas(300, 200);
  background(200,200,0);
  var qtest = createElement('p', question);
  qtest.position(10,7);
  var inp = createInput();
  inp.position(100,20);
  inp.input(myInputEvent);
}

function myInputEvent() { 
  console.log('you are typing: ', this.value());
}

SNAG-0115

1 Like
let inp;

function setup() {
  inp = createInput().attribute('placeholder', 'hint');
}
2 Likes

thank you very much for the help