当前位置: 首页>>代码示例>>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;未经允许,请勿转载。