Disable backspace (keyPressed)

edited February 2017 in How To...

Hi, I'm trying to create text editor where it's not possible to delete what was written / I'm trying to disable backspace. I tried with keyPressed

void keyPressed() { if (keyCode == BACKSPACE) keyCode=0; }

but it's not working and google isn't helpful. Plz help

Answers

  • when you use myInput += key;

    and you don't check backspace, backspace doesn't work in the first place

  • edited February 2017

    Using Processing 3.3 and Win10 .... it seems like your code should work. I tried your code and keyCode is returned as a value of 37. For some strange reason the code fragment below translates the BACKSPACE keyCode to zero:

    void keyPressed() { 
      if (keyCode == 37) keyCode = 0; 
      println(keyCode);
    }
    
  • I got 127 for Del and 8 for bckspc.

    void keyPressed() {   
      println("Detected key="+char(key)+ " " + int(key));  
      println("Detected keyCode="+char(keyCode)+ " " + int(keyCode));
    }
    

    Kf

  • thanks guys, but it didnt work for me. in the end i used

    void keyTyped() { if (key >= 9 && key <= 999) { letter = key; words = words + key; println(key); }

  • @kfrajer You are correct Sir...my bad...I was using the 'Cursor Left' key. #-o

Sign In or Register to comment.