controlP5 submit on keypress

edited December 2015 in Library Questions

Hi folks --

so, simple little thing, but I’m not familiar with much programming beyond processing, which is I’m sure why I’m having problems with it...

I want to have users enter text, hit the enter button and then do something with that text. It’s for an art installation and I’m not even going to GIVE them a mouse, which is why I can’t use the textfield example verbatim.

Basically (I think) I want to change the bang here to a ControlKey:

cp5.addTextfield("textInput_1").setPosition(20, 100).setSize(200, 40).setAutoClear(false); cp5.addBang("Submit").setPosition(240, 170).setSize(80, 40);

Thanks in advance!

Answers

  • Help, help? Anyone? :( Thanks!

  • Answer ✓

    GOT IT!

    Get rid of the addBang line, use: cp5.mapKeyFor(new ControlKey() {public void keyEvent() { Submit(); }}, ENTER);

Sign In or Register to comment.