Index / 2017 / Better Text Input
№ 39

Better Text Input

500×500 · p5.js instance mode
Better_Text_Input.pde 25 lines
String myText = "Type something";
 
void setup() {
  size(500, 500);
  textAlign(CENTER, CENTER);
  textSize(30);
  fill(0);
}
 
void draw() {
  background(255);
  text(myText, 0, 0, width, height);
}
 
void keyPressed() {
  if (keyCode == BACKSPACE) {
    if (myText.length() > 0) {
      myText = myText.substring(0, myText.length()-1);
    }
  } else if (keyCode == DELETE) {
    myText = "";
  } else if (keyCode != SHIFT && keyCode != CONTROL && keyCode != ALT) {
    myText += key;
  }
}
read-only archive source from /2017/Useful References/Better_Text_Input/Better_Text_Input.pde

Description

This page is generated from the Processing project folder at /2017/Useful References/Better_Text_Input/Better_Text_Input.pde.

Archive

No companion assets were found in this sketch folder.