how to type word in console like with the librairie scanner.

hello I'd like to type words in the processing console and print it with the println function for ex. i tried to use scanner librairie but my program stopped and i must restart processing interface thanks for your help

Tagged:

Answers

  • Are you talking about the console in the Processing editor? As far as I know you can't enter any text there.

    If you really want to enter text via a console, you're going to have to export your application and then run it via a command prompt.

    The only other option is to create your own console.

  • edited September 2016

    If on the other hand you only want your text to appear in the console, and don't mind clicking on the sketch window to give it keyboard focus, then this is very simple to do.

    /** console typing
     *  2016-09-13 Processing 3.2.1
     *  click in sketch window and type -- text appears in console
     */
    void setup(){
      textAlign(CENTER,CENTER);
      textSize(32);
    }
    void draw(){
      background(0);
      text(key,width/2,height/2);
    }
    void keyTyped(){
      print(key);
    }
    

    How do I print the key anytime a key is typed?

    void keyTyped(){ print(key); }
    

    Change to println() if you want linebreaks between each key.

Sign In or Register to comment.