Shift Key Creating Box Character

When I input characters, my shift keys are producing a box character when pressed. For example, if I’m typing the name Bob, it comes up as [box]Bob. How can I prevent this?

This is for console output by the way.

Processing.org/reference/keyTyped_.html

I assume SHIFT is CODED

https://processing.org/reference/keyCode.html

Neither solves the problem here. I can no longer input text with keyTyped since it prints after pressing the enter key and now enter is not being recognized.
The CODED bit did not work.
I just want to know how to avoid the boxes when pressing Shift.

if(keyCode!=SHIFT) 
    str+=key;

code WITH the box issue:

String input=""; 

void setup() {
  size(600, 600);
  background(0);
}

void draw() {
  background(0);
  text(input, 
    23, 23);
}

void keyPressed() {
  input += key;
}

code without the issue:

using CODED

String input=""; 

// cursor sign blinks 
boolean cursorBlinkFlag; 
int timerCursorBlink;

void setup() {
  size(600, 600);
  background(0);
}

void draw() {
  background(0);

  fill(255);
  text(input, 
    23, 23);
  showBlinkingCursor(input);
}

// --------------------------------------------------------------------

void keyPressed() {
  if (key == CODED) {
    // CODED: SHIFT, UP, DOWN, etc. 
    if (keyCode == UP) {
      //
    } else if (keyCode == DOWN) {
      //
    }//else if
  } 
  // ----------------------------------------------
  else {
    // NOT  CODED
    // add as input
    input += key;
  }//else
  //
}//func 

// --------------------------------------------------------------------

void showBlinkingCursor(String oneLine) {
  // manage and show the red Blinking Cursor |

  if (cursorBlinkFlag) {
    // show text cursor
    fill(255, 0, 0); // RED 
    text("|", 
      23 + textWidth(oneLine), 23);
    // back to normal
    fill(255);
  }//if

  // timer to toggle the flag cursorBlinkFlag
  if (millis()-timerCursorBlink > 330) {
    cursorBlinkFlag  = !cursorBlinkFlag; // toggle
    timerCursorBlink = millis();
  }//if
}
//
1 Like