processing.event.KeyEvent类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(229)

本文整理了Java中processing.event.KeyEvent类的一些代码示例,展示了KeyEvent类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent类的具体详情如下:
包路径:processing.event.KeyEvent
类名称:KeyEvent

KeyEvent介绍

暂无

代码示例

代码示例来源:origin: org.processing/core

protected void handleKeyEvent(KeyEvent event) {
 if (!keyRepeatEnabled && event.isAutoRepeat()) return;
 key = event.getKey();
 keyCode = event.getKeyCode();
 switch (event.getAction()) {
 case KeyEvent.PRESS:
  Long hash = ((long) keyCode << Character.SIZE) | key;
 if (event.getAction() == KeyEvent.PRESS) {
    event.getKeyCode() == 'W' &&
    ((event.isMetaDown() && platform == MACOSX) ||
     (event.isControlDown() && platform != MACOSX))) {

代码示例来源:origin: poqudrof/PapARt

if (e.isAltDown() || !useAlt) {
  if (e.getAction() == KeyEvent.PRESS) {
        && (e.getKey() == saveKey.charAt(0))) {
      System.out.println("Saved to : " + filename);
      this.saveLocationTo(filename);
        && (e.getKey() == trackKey.charAt(0))) {
      this.useManualLocation(!this.useManualLocation, null);
      String status = useManualLocation ? "ON" : "OFF";
        && (e.getKey() == loadKey.charAt(0))) {
      this.loadLocationFrom(filename);
      System.out.println("Loaded from: " + filename);

代码示例来源:origin: ajavamind/Processing-Cardboard

protected void handleKeyEvent(KeyEvent event) {
//    keyEvent = event;
    key = event.getKey();
    keyCode = event.getKeyCode();

    switch (event.getAction()) {
      case KeyEvent.PRESS:
        keyPressed = true;
        keyPressed(event);
        break;
      case KeyEvent.RELEASE:
        keyPressed = false;
        keyReleased(event);
        break;
    }

    handleMethods("keyEvent", new Object[]{event});
  }

代码示例来源:origin: ruby-processing/JRubyArt

/**
 * key event to register
 *
 * @param e KeyEvent
 */
public void keyEvent(processing.event.KeyEvent e) {
  if (e.getAction() != KeyEvent.PRESS) {
  } else {
    switch (e.getKey()) {
      case 'x':
        constrain(Constrain.XAXIS);
        break;
      case 'y':
        constrain(Constrain.YAXIS);
        break;
      case 'z':
        constrain(Constrain.ZAXIS);
        break;
    }
  }
  if (e.getAction() == KeyEvent.RELEASE) {
    constrain(Constrain.FREE);
  }
}

代码示例来源:origin: ajavamind/Processing-Cardboard

protected void nativeKeyEvent(android.view.KeyEvent event) {
  // event.isPrintingKey() returns false for whitespace and others,
  // which is a problem if the space bar or tab key are used.
  char key = (char) event.getUnicodeChar();
  // if not mappable to a unicode character, instead mark as coded key
  if (key == 0 || key == 0xFFFF) {
    key = CODED;
  }
  int keyCode = event.getKeyCode();
  int keAction = 0;
  int action = event.getAction();
  if (action == android.view.KeyEvent.ACTION_DOWN) {
    keAction = KeyEvent.PRESS;
  } else if (action == android.view.KeyEvent.ACTION_UP) {
    keAction = KeyEvent.RELEASE;
  }
  // TODO set up proper key modifier handling
  int keModifiers = 0;
  KeyEvent ke = new KeyEvent(event, event.getEventTime(),
      keAction, keModifiers, key, keyCode);
  postEvent(ke);
}

代码示例来源:origin: evolvio/evolv.io

public void handleKeyEvent(KeyEvent keyEvent) {
 int keyActionConstant = keyEvent.getAction();
 KeyAction keyAction = KeyAction.getFromConstant(keyActionConstant);
 char key = keyEvent.getKey();
 if (key == PConstants.CODED) {
   int keyCodeConstant = keyEvent.getKeyCode();
   KeyCode keyCode = KeyCode.getFromConstant(keyCodeConstant);
   performAction(keyAction, keyCode, keyCodeActions, keyEvent);
 } else {
   performAction(keyAction, key, keyActions, keyEvent);
 }
}

代码示例来源:origin: org.processing/core

protected void nativeKeyEvent(java.awt.event.KeyEvent event) {
  int peAction = 0;
  switch (event.getID()) {
  case java.awt.event.KeyEvent.KEY_PRESSED:
   peAction = KeyEvent.PRESS;
   break;
  case java.awt.event.KeyEvent.KEY_RELEASED:
   peAction = KeyEvent.RELEASE;
   break;
  case java.awt.event.KeyEvent.KEY_TYPED:
   peAction = KeyEvent.TYPE;
   break;
  }

//    int peModifiers = event.getModifiersEx() &
//      (InputEvent.SHIFT_DOWN_MASK |
//       InputEvent.CTRL_DOWN_MASK |
//       InputEvent.META_DOWN_MASK |
//       InputEvent.ALT_DOWN_MASK);
  int peModifiers = event.getModifiers() &
   (InputEvent.SHIFT_MASK |
    InputEvent.CTRL_MASK |
    InputEvent.META_MASK |
    InputEvent.ALT_MASK);

  sketch.postEvent(new KeyEvent(event, event.getWhen(),
                 peAction, peModifiers,
                 event.getKeyChar(), event.getKeyCode()));
 }

代码示例来源:origin: org.processing/core

protected void fxKeyEvent(javafx.scene.input.KeyEvent fxEvent) {
 int action = 0;
 EventType<? extends KeyEvent> et = fxEvent.getEventType();
 if (et == KeyEvent.KEY_PRESSED) {
  action = processing.event.KeyEvent.PRESS;
 } else if (et == KeyEvent.KEY_RELEASED) {
  action = processing.event.KeyEvent.RELEASE;
 } else if (et == KeyEvent.KEY_TYPED) {
  action = processing.event.KeyEvent.TYPE;
 }
 int modifiers = 0;
 if (fxEvent.isShiftDown()) {
  modifiers |= processing.event.Event.SHIFT;
 }
 if (fxEvent.isControlDown()) {
  modifiers |= processing.event.Event.CTRL;
 }
 if (fxEvent.isMetaDown()) {
  modifiers |= processing.event.Event.META;
 }
 if (fxEvent.isAltDown()) {
  modifiers |= processing.event.Event.ALT;
 }
 long when = System.currentTimeMillis();
 char keyChar = getKeyChar(fxEvent);
 int keyCode = getKeyCode(fxEvent);
 sketch.postEvent(new processing.event.KeyEvent(fxEvent, when,
                         action, modifiers,
                         keyChar, keyCode));
}

代码示例来源:origin: org.processing/core

KeyEvent ke = new KeyEvent(nativeEvent, nativeEvent.getWhen(),
              peAction, peModifiers,
              keyChar,
  KeyEvent tke = new KeyEvent(nativeEvent, nativeEvent.getWhen(),
                KeyEvent.TYPE, peModifiers,
                keyChar,

相关文章