當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.VK_LEFT屬性代碼示例

本文整理匯總了Java中java.awt.event.KeyEvent.VK_LEFT屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.VK_LEFT屬性的具體用法?Java KeyEvent.VK_LEFT怎麽用?Java KeyEvent.VK_LEFT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.VK_LEFT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: keyReleased

@Override
public void keyReleased(final @NonNull KeyEvent e) {
    switch (e.getKeyCode()) {
        case KeyEvent.VK_UP:
        case KeyEvent.VK_W: {
            map.getPlayer().move(0, -1);
            break;
        }
        case KeyEvent.VK_DOWN:
        case KeyEvent.VK_S: {
            map.getPlayer().move(0, 1);
            break;
        }
        case KeyEvent.VK_LEFT:
        case KeyEvent.VK_A: {
            map.getPlayer().move(-1, 0);
            break;
        }
        case KeyEvent.VK_RIGHT:
        case KeyEvent.VK_D: {
            map.getPlayer().move(1, 0);
            break;
        }
    }
}
 
開發者ID:Valkryst,項目名稱:VRoguelike,代碼行數:25,代碼來源:GameScreen.java

示例2: keyPressed

@Override
public void keyPressed(KeyEvent e) {
    int step = e.isControlDown() ? 50 : e.isAltDown() ? 1 : 5;
    switch (e.getKeyCode()) {
        case KeyEvent.VK_LEFT:
            setLocation(getX() - step, getY());
            break;
        case KeyEvent.VK_RIGHT:
            setLocation(getX() + step, getY());
            break;
        case KeyEvent.VK_UP:
            setLocation(getX(), getY() - step);
            break;
        case KeyEvent.VK_DOWN:
            setLocation(getX(), getY() + step);
            break;
        case KeyEvent.VK_ESCAPE:
            exitAction.actionPerformed(null);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:Ruler.java

示例3: checkInput

public void checkInput() {
		KeyEvent event = buffer.pop();
		if (event != null){
			if (event.getID() == java.awt.event.KeyEvent.KEY_PRESSED){
				switch(event.getKeyCode()) {
				case KeyEvent.VK_UP:
					snake.setDirection('U');
					break;
				case KeyEvent.VK_DOWN:
					snake.setDirection('D');
					break;
				case KeyEvent.VK_LEFT:
					snake.setDirection('L');
					break;
				case KeyEvent.VK_RIGHT:
					snake.setDirection('R');
					break;
				}
				
			}
			//System.out.println(event.getKeyCode());
		}
		buffer.clear();
}
 
開發者ID:JonathanTheZero,項目名稱:LEDBoard-Game-Collection,代碼行數:24,代碼來源:ScreenOne.java

示例4: processKeyEvent

@Override
public void processKeyEvent(java.awt.event.KeyEvent e, JXLayer<? extends V> l) {
    if (e.getID() != KeyEvent.KEY_PRESSED) {
        // We are only interested in KEY_PRESSED event.
        return;
    }
    final int code = e.getKeyCode();
    switch(code) {
        case KeyEvent.VK_LEFT:
            this.updateTraceInfosIfPossible(-1);
            break;
        case KeyEvent.VK_RIGHT:
            this.updateTraceInfosIfPossible(+1);
            break;
    }
}
 
開發者ID:lead4good,項目名稱:open-java-trade-manager,代碼行數:16,代碼來源:ChartLayerUI.java

示例5: keyReleased

public void keyReleased(KeyEvent evt){
    switch(evt.getKeyCode()){
        case KeyEvent.VK_LEFT:
            bool_left = false;
            bool_left2 = false;
            if (bool_right2 == true){
                bool_right = true;
            }
        break;
        case KeyEvent.VK_RIGHT:
            bool_right = false;
            bool_right2 = false;
            if (bool_left2 == true){
                bool_left = true;
            }
        break;
    }
}
 
開發者ID:Dexor157,項目名稱:collidethings,代碼行數:18,代碼來源:Game.java

示例6: keyPressed

public void keyPressed(KeyEvent e) {
  if( e.getKeyCode() == KeyEvent.VK_DOWN ) {
    master.xlateDown();
    master.fastRefresh();
  }
  if( e.getKeyCode() == KeyEvent.VK_UP ) {
    master.xlateUp();
    master.fastRefresh();
  }
  if( e.getKeyCode() == KeyEvent.VK_LEFT ) {
    master.xlateLeft();
    master.fastRefresh();
  }
  if( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
    master.xlateRight();
    master.fastRefresh();
  }
}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:18,代碼來源:KeyboardControl.java

示例7: keyReleased

@Override
synchronized public void keyReleased(int keycode) {
    switch (keycode)
    {
        case KeyEvent.VK_UP:
            up = false;
            break;
        case KeyEvent.VK_DOWN:
            down = false;
            break;
        case KeyEvent.VK_LEFT:
            left = false;
            break;
        case KeyEvent.VK_RIGHT:
            right = false;
            break;
        case KeyEvent.VK_SPACE:
            space = false;
            break;
        default:
            break;
    }
}
 
開發者ID:Silvanosky,項目名稱:StellarCrush,代碼行數:23,代碼來源:MainKeyListener.java

示例8: keyPressed

public void keyPressed(KeyEvent e) {

      /*
       * Pass key onto window scroller if no region selected
       * or control key not used.
       */
      if (selectedRegions.isEmpty() || !e.isControlDown())
        return;

      int dx = 0, dy = 0, delta = 1;

      if (e.isShiftDown()) {
        delta = 5;
      }

      switch (e.getKeyCode()) {
        case KeyEvent.VK_UP:
          dy = -delta;
          break;
        case KeyEvent.VK_DOWN:
          dy = delta;
          break;
        case KeyEvent.VK_LEFT:
          dx = -delta;
          break;
        case KeyEvent.VK_RIGHT:
          dx = delta;
          break;
        default :
          return;
      }

      for (Region r : selectedRegions) {
        r.move(dx, dy, view);
      }

      view.repaint();
      e.consume();
    }
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:39,代碼來源:RegionGrid.java

示例9: keyPressed

public void keyPressed(KeyEvent e) {
    int keyc = e.getKeyCode();
    if (keyc == KeyEvent.VK_UP || keyc == KeyEvent.VK_DOWN
            || keyc == KeyEvent.VK_LEFT || keyc == KeyEvent.VK_RIGHT) {
        // System.err.println("arrow key released");
        ActionEvent action = new ActionEvent(e.getSource(),
                ActionEvent.ACTION_PERFORMED, InputGUI.GRAMSEL);
        g.actionPerformed(action);
    }
}
 
開發者ID:spetitjean,項目名稱:TuLiPA-frames,代碼行數:10,代碼來源:InputGUI.java

示例10: keyEventReceived

@Override
public KeyConfigurationResult keyEventReceived(KeyConfigurationEvent event) {
	if (event.getType() == KeyConfigurationEvent.KEY_PRESSED) {
		KeyEvent e = event.getKeyEvent();
		if (e.getModifiersEx() == modsEx) {
			Direction value = null;
			switch (e.getKeyCode()) {
			case KeyEvent.VK_UP:
				value = Direction.NORTH;
				break;
			case KeyEvent.VK_DOWN:
				value = Direction.SOUTH;
				break;
			case KeyEvent.VK_LEFT:
				value = Direction.WEST;
				break;
			case KeyEvent.VK_RIGHT:
				value = Direction.EAST;
				break;
			}
			if (value != null) {
				event.consume();
				return new KeyConfigurationResult(event, attr, value);
			}
		}
	}
	return null;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:28,代碼來源:DirectionConfigurator.java

示例11: keyPressed

@Override
public void keyPressed(KeyEvent e) {
	int key = e.getKeyCode();
	//System.out.println("human pressed " + key);
	
	if (key == KeyEvent.VK_UP || key == KeyEvent.VK_KP_UP) {
		// UP means accelerate forward
		lastKeyPressed = HumanKeyPressed.UP;
		//System.out.println("human pressed UP ");
	} else if (key == KeyEvent.VK_DOWN || key == KeyEvent.VK_KP_DOWN) {
		// DOWN means decelerate
		lastKeyPressed = HumanKeyPressed.DOWN;
	} else if (key == KeyEvent.VK_RIGHT || key == KeyEvent.VK_KP_RIGHT) {
		// turn RIGHT
		lastKeyPressed = HumanKeyPressed.RIGHT;
	} else if (key == KeyEvent.VK_LEFT || key == KeyEvent.VK_KP_LEFT) {
		// turn LEFT
		lastKeyPressed = HumanKeyPressed.LEFT;
	} else if (key == KeyEvent.VK_SPACE) {
		// fire
		lastKeyPressed = HumanKeyPressed.FIRE;
	}
	
	if (lastKeyPressed != null) {
		lastMouseClick = null;
	}
}
 
開發者ID:amymcgovern,項目名稱:spacesettlers,代碼行數:27,代碼來源:HumanTeamClient.java

示例12: letTextPaneHandleKey

private boolean letTextPaneHandleKey(KeyEvent ke) {
    return ke.getKeyCode() == KeyEvent.VK_LEFT ||
            ke.getKeyCode() == KeyEvent.VK_RIGHT ||
            ke.getKeyCode() == KeyEvent.VK_UP ||
            ke.getKeyCode() == KeyEvent.VK_DOWN ||
            ke.getKeyChar()== KeyEvent.VK_ESCAPE;                
}
 
開發者ID:Skypr,項目名稱:BEAST,代碼行數:7,代碼來源:UserInputHandler.java

示例13: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent e) {
	if(!Menu.menu.isVisible()){
		if(e.getID() == KeyEvent.KEY_PRESSED){
			int d = e.isShiftDown() ? 3 : e.isControlDown() ? 2 : 1;
			switch(e.getKeyCode()){
			case KeyEvent.VK_LEFT:
			case KeyEvent.VK_KP_LEFT:
				e.getComponent().getLocation(tmp);
				e.getComponent().setLocation(tmp.x - d, tmp.y);
				break;
			case KeyEvent.VK_RIGHT:
			case KeyEvent.VK_KP_RIGHT:
				e.getComponent().getLocation(tmp);
				e.getComponent().setLocation(tmp.x + d, tmp.y);
				break;
			case KeyEvent.VK_UP:
			case KeyEvent.VK_KP_UP:
				e.getComponent().getLocation(tmp);
				e.getComponent().setLocation(tmp.x, tmp.y - d);
				break;
			case KeyEvent.VK_DOWN:
			case KeyEvent.VK_KP_DOWN:
				e.getComponent().getLocation(tmp);
				e.getComponent().setLocation(tmp.x, tmp.y + d);
				break;
			}
		}
	}
	return false;
}
 
開發者ID:RoanH,項目名稱:KeysPerSecond,代碼行數:31,代碼來源:Listener.java

示例14: keyPressed

@Override
public void keyPressed(KeyEvent e) {
    if (diagramaAtual != null) {
        switch (e.getKeyCode()) {
            case KeyEvent.VK_LEFT:
            case KeyEvent.VK_RIGHT:
            case KeyEvent.VK_UP:
            case KeyEvent.VK_DOWN:
            case KeyEvent.VK_ESCAPE:
            case KeyEvent.VK_ENTER:
                diagramaAtual.ProcesseTeclas(e);
                break;
            case KeyEvent.VK_DELETE:
                if (diagramaAtual != null) {
                    diagramaAtual.deleteSelecao();
                    e.consume();
                }
                break;
            case KeyEvent.VK_TAB:
                if (e.isControlDown()) {
                    if (e.isShiftDown()) {
                        if (diagramaAtual.SelecioneAnterior()) {
                            e.consume();
                        }
                    } else if (diagramaAtual.SelecioneProximo()) {
                        e.consume();
                    }
                } else {
                    transferFocus();
                }
                break;
        }
    }
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:34,代碼來源:Editor.java

示例15: ModifierRobotEnhancedKeyTest

public ModifierRobotEnhancedKeyTest() throws Exception {
    modifierKeys =  new int[4];
    modifierKeys[0] = KeyEvent.VK_SHIFT;
    modifierKeys[1] = KeyEvent.VK_CONTROL;
    modifierKeys[2] = KeyEvent.VK_ALT;
    modifierKeys[3] = KeyEvent.VK_ALT_GRAPH;

    inputMasks = new int[4];
    inputMasks[0] =  InputEvent.SHIFT_MASK;
    inputMasks[1] =  InputEvent.CTRL_MASK;
    inputMasks[2] =  InputEvent.ALT_MASK;
    inputMasks[3] =  InputEvent.ALT_GRAPH_MASK;

    modifierStatus = new boolean[modifierKeys.length];

    textKeys = new int[6];
    textKeys[0] = KeyEvent.VK_A;
    textKeys[1] = KeyEvent.VK_S;
    textKeys[2] = KeyEvent.VK_DELETE;
    textKeys[3] = KeyEvent.VK_HOME;
    textKeys[4] = KeyEvent.VK_F12;
    textKeys[5] = KeyEvent.VK_LEFT;

    textStatus = new boolean[textKeys.length];

    EventQueue.invokeAndWait( () -> { initializeGUI(); });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:ModifierRobotEnhancedKeyTest.java


注:本文中的java.awt.event.KeyEvent.VK_LEFT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。