Handle key events in RichTextArea

Is it possible to handle shortcuts (key press events) in RichTextArea (editable area)?

For example:

  • handle CTRL+ENTER keystroke
  • move focus out of RichTextArea to the next focusable component in window when pressing CTRL + RIGHT ARROW

Unfortunately, ShortcutListener doesn’t work for this component. Try yourself.

You can add a ShortCutListener to the RichTextArea.


RichTextArea area = new RichTextArea();
 area.addShortcutListener(
                new ShortcutListener("", KeyCode.ARROW_DOWN, KeyCode.CTRL) {

                    @Override
                    public void handleAction(Object sender, Object target) {
                        otherField.focus();
                    }
  });