I am using a vaadin TextArea as a rough console. The user can enter commands which should be executed when he presses the enter key. Is there a way to specify this with a listener on the TextArea?
The closest thing I found is to use:
TextArea textArea = new TextArea();
textArea.addTextChangeListener(this);
textArea.setTextChangeEventMode(TextChangeEventMode.EAGER);
And handle the text change event:
@Override
public void textChange(TextChangeEvent event) {
System.out.println(event.getText());
}
This is however triggered as soon as text has been entered in the TextArea. I would like to be notified only when the enter key has been pressed.