GWT register key event from text field

Hey, I am running GWT on ubuntu and trying to learn by following the tutorial guide found on Google . I have a problem creating a register of a text field when the user presses the enter button. It works with an arbitrary definition, so I don't think this is a problem with the code. So it is probably KeyCodes.KEY_ENTERnot supported on Linux? What else can I write instead to read it when the user presses the enter button?

    newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {
      public void onKeyPress(KeyPressEvent event) {
        if (event.getCharCode() == KeyCodes.KEY_ENTER) {
          addStock();
          System.out.println("Foo");
        }
      }
    });
+3
source share
2 answers

Use the method getKeyCode()that you find in your own event.

if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER)
  System.out.println("Foo");
+5
source

, KeyCodes.KEY_ENTER Linux, :

event.getCharCode() == 13
+1

Source: https://habr.com/ru/post/1786632/


All Articles