本文整理汇总了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;
}
}
}
示例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);
}
}
示例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();
}
示例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;
}
}
示例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;
}
}
示例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();
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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(); });
}