GWT Polymer UiBinder Elements addEventListener Event KeysPressedEvent

I’m trying to follow the basic hello world examples that use GWT Polymer with the UiBinder Elements.
The basic GWT example stub generated code handles the key to specify input.
I thought it would be easy to have an event handler and check the key that was pressed.

I’m probably doing something very basic wrong.
Maybe some
I’m not doing or
I forgot to include.

The event does trigger but I get undefined when I attempt to get the key from the event.
I guessed using “keypress” as the other examples use “click” and it did trigger but what is the right type to use?
I outputed some of the values and get the following:

→ undefined

→ [object KeyboardEvent]

→ <paper-input-container class

→ show what was typed before processing the current key

I also need to know what the string value or Constant to use for the key to do the test.
Please advise how to make this work using the event listener.

Here is my current code:

Main.ui.xml file
        <paper-fab ui:field="sendButton" icon="gavel" title="send rpc" class="sendrpc" />
        <paper-dialog ui:field="sendMsgDialog" entry-animation="fade-in-animation"
            class="dialog" modal="">
            <h2>Send RPC to Server</h2>
            <paper-input ui:field="nameFieldInput" label="Please enter your name:"
                required="" auto-validate="" pattern="[a-zA-Z]
                minlength="4" char-counter="" error-message="required input!"/>
            <div class="buttons">
                <paper-button dialog-dismiss="">Cancel</paper-button>
                <paper-button ui:field="sendFieldButton"
        </paper-dialog> class

  @UiField PaperInputElement nameFieldInput;

   nameFieldInput.addEventListener("keypress",  new EventListener<KeysPressedEvent>() {
      public void handleEvent(KeysPressedEvent event) {
          if (event.getDetail().getKey() == "enter" && event.getDetail().getCtrl() == false) {

I used the two following examples documents to get to this point and they show the following examples of using the listener. Unfortunately the gwtproject example only uses the event trigger and does not use the event object information…


@UiField PaperFabElement addButton;


public Main() {
  addButton.addEventListener("click", new EventListener() {
    public void handleEvent(Event event) {;


@UiField PaperTabsElement paperTabs;

paperTabs.addEventListener(IronSelectEvent.NAME, new EventListener() {
public void handleEvent(IronSelectEvent event) {
PaperTabElement tab = (PaperTabElement)event.getDetail().getItem();
toast.setText(“Tab "” + tab.getTextContent() + “" has been selected”);;
[/code]Here is an example that uses GWT standard Ui instead of polymer from

z.ui.xml file
<g:HorizontalPanel ui:field="hPanel">
      <g:Button ui:field="sendButton" text="Send"
       styleName="{style.sendButton}" />
      <g:TextBox ui:field="nameField" text="GWT User" />
    </g:HorizontalPanel> file
  HorizontalPanel hPanel;
  Button sendButton;
  TextBox nameField;

  //Fired when user clicks send Button
  public void sendOnClick(ClickEvent event){

  //Fired when user types in the nameField.
  public void nameOnKeyUp(KeyUpEvent event){
    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER){

With the help from stackoverflow I have the answer.
I’ll post it hear for those with the same issue.

 sendButton.addEventListener("click", new EventListener() {
public void handleEvent(Event event) {;


nameFieldInput.addEventListener("keyup", new EventListener<KeysPressedEvent>() {
public void handleEvent(KeysPressedEvent event) {
NativeEvent nativeEvent = (NativeEvent)event;
// CharCode is blank unless you use "keypress" as the event
// nameFieldInput.setErrorMessage(nativeEvent.getCharCode()+":"+nativeEvent.getKeyCode()+":"+nativeEvent.getAltKey()+":"+nativeEvent.getCtrlKey()+":"+nativeEvent.getMetaKey()+":"+nativeEvent.getShiftKey());
if (nativeEvent.getKeyCode() == KeyCodes.KEY_ENTER
&& !nativeEvent.getAltKey() && !nativeEvent.getCtrlKey()
&& !nativeEvent.getMetaKey() && !nativeEvent.getShiftKey()) {