code: protected void registerPreviewHandler() {
  
          if (m_previewHandlerRegistration == null) {
              NativePreviewHandler eventPreviewHandler = new NativePreviewHandler() {
  
                  public void onPreviewNativeEvent(NativePreviewEvent event) {
  
                      Event nativeEvent = Event.as(event.getNativeEvent());
                      if (DOM.eventGetType(nativeEvent) == Event.ONKEYDOWN) {
                          int keyCode = nativeEvent.getKeyCode();
                          if (keyCode == KeyCodes.KEY_ESCAPE) {
                              onClickCancel();
                          } else if (keyCode == KeyCodes.KEY_ENTER) {
                              Element element = CmsDomUtil.getActiveElement();
                              boolean isTextarea = (element != null) && element.getTagName().equalsIgnoreCase("textarea");
                              if (!isTextarea) {
                                  onClickOk();
                              }
                          }
                      }
                  }
              };
              m_previewHandlerRegistration = Event.addNativePreviewHandler(eventPreviewHandler);
          }
      }
docs: Registers the 'Enter' and 'Esc' shortcut action handler.<p>