Ejemplo n.º 1
0
 /**
  * The onKeyPress method handles all keys that were held down and then lifted up, after the
  * KeyDown and KeyUp events are triggered
  */
 @Override
 public void onKeyPress(KeyPressEvent event) {
   code = new Code(event);
   if (code.getCharCode() > 31 && code.getCharCode() < 127) {
     processCode(code);
     event.getNativeEvent().stopPropagation();
     event.getNativeEvent().preventDefault();
   }
 }
Ejemplo n.º 2
0
  /**
   * The processCode method deciphers each key press or combination of key presses and converts them
   * into VT100 format bytes
   *
   * @param c Key/Char code
   */
  public void processCode(Code c) {
    int k = 0;
    boolean isCharCode = false;
    if (c.getCharCode() != 0) {
      k = c.getCharCode();
    } else if (c.getKeyCode() != 0) k = c.getKeyCode();

    if (c.isCtrlDown()) {
      k = ctrlPressed(k);
      if (k == -1) return;
    } else if (c.isFunctionKey() || c.isAltDown()) {
      k = fromKeyDownSwitch(k);
      if (k == -1) return;
    }
    if (buildCharacter(k, isCharCode) != null) {
      queue(buildCharacter(k, isCharCode));
    }
  }