Java Code Examples for java.awt.event.KeyEvent#VK_D

The following examples show how to use java.awt.event.KeyEvent#VK_D . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenTCSDrawingView.java    From openAGV with Apache License 2.0 6 votes vote down vote up
@Override
public void processKeyEvent(KeyEvent e) {
  if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
    // Cut, copy, paste and duplicate
    if (e.getKeyCode() == KeyEvent.VK_X
        || e.getKeyCode() == KeyEvent.VK_C
        || e.getKeyCode() == KeyEvent.VK_V
        || e.getKeyCode() == KeyEvent.VK_D) {
      if (!appState.hasOperationMode(OperationMode.MODELLING)) {
        return;
      }
      processCutPasteKeyEvent();
    }
  }

  super.processKeyEvent(e);
}
 
Example 2
Source File: Block.java    From JavaGame with MIT License 6 votes vote down vote up
/**
 * ���̰����¼�
 * 
 * @param e
 */
public void keyPressed(KeyEvent e) {
	switch (e.getKeyCode()) {
	case KeyEvent.VK_UP:
	case KeyEvent.VK_W:
		rotate = true;
		down = left = right = false;
		break;
	case KeyEvent.VK_DOWN:
	case KeyEvent.VK_S:
		down = true;
		rotate = left = right = false;
		break;
	case KeyEvent.VK_LEFT:
	case KeyEvent.VK_A:
		left = true;
		rotate = right = down = false;
		break;
	case KeyEvent.VK_RIGHT:
	case KeyEvent.VK_D:
		right = true;
		rotate = left = down = false;
		break;
	}
}
 
Example 3
Source File: Plane.java    From JavaGame with MIT License 6 votes vote down vote up
/**
 * ���¼��̵ķ���
 * 
 * @param e
 */
public void keyPressed(KeyEvent e) {
	switch (e.getKeyCode()) {
	case KeyEvent.VK_A:
		left = true;
		break;
	case KeyEvent.VK_S:
		down = true;
		break;
	case KeyEvent.VK_D:
		right = true;
		break;
	case KeyEvent.VK_W:
		up = true;
		break;
	case KeyEvent.VK_J:// ���ӵ�
		superFire = false;
		fire = true;
		break;
	case KeyEvent.VK_SPACE:// �������ӵ�
		fire = false;
		superFire = true;
		break;
	}
}
 
Example 4
Source File: KeyManager.java    From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
public void tick(){
	for(int i = 0;i < keys.length;i++){
		if(cantPress[i] && !keys[i]){
			cantPress[i] = false;
		}else if(justPressed[i]){
			cantPress[i] = true;
			justPressed[i] = false;
		}
		if(!cantPress[i] && keys[i]){
			justPressed[i] = true;
		}
	}
	
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
	
	aUp = keys[KeyEvent.VK_UP];
	aDown = keys[KeyEvent.VK_DOWN];
	aLeft = keys[KeyEvent.VK_LEFT];
	aRight = keys[KeyEvent.VK_RIGHT];
}
 
Example 5
Source File: KeyManager.java    From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
public void tick(){
	for(int i = 0;i < keys.length;i++){
		if(cantPress[i] && !keys[i]){
			cantPress[i] = false;
		}else if(justPressed[i]){
			cantPress[i] = true;
			justPressed[i] = false;
		}
		if(!cantPress[i] && keys[i]){
			justPressed[i] = true;
		}
	}
	
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
	
	aUp = keys[KeyEvent.VK_UP];
	aDown = keys[KeyEvent.VK_DOWN];
	aLeft = keys[KeyEvent.VK_LEFT];
	aRight = keys[KeyEvent.VK_RIGHT];
}
 
Example 6
Source File: NativeDisplayKeyListener.java    From salty-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressed(final KeyEvent e) {

    if (keyboardHandler != null) {
        keyboardHandler.keyPressed(e);
    }

    currentKey = e.getKeyChar();

    if (e.getKeyCode() == KeyEvent.VK_W || e.getKeyCode() == KeyEvent.VK_UP) {

        inputUp = true;
    }
    if (e.getKeyCode() == KeyEvent.VK_S || e.getKeyCode() == KeyEvent.VK_DOWN) {

        inputDown = true;
    }
    if (e.getKeyCode() == KeyEvent.VK_A || e.getKeyCode() == KeyEvent.VK_LEFT) {

        inputLeft = true;
    }
    if (e.getKeyCode() == KeyEvent.VK_D || e.getKeyCode() == KeyEvent.VK_RIGHT) {

        inputRight = true;
    }

    if (SceneManager.getCurrentScene().getUI() != null) {
        SceneManager.getCurrentScene().getUI().keyPressed(e);
    }

    Input.keyboardInput.handleKeyPressed(e);
    updateInputStates();
    Input.lastInput = e;
    Input.getKeyboardHandlers().forEach(keyboardInputHandler -> keyboardInputHandler.keyPressed(e));
}
 
Example 7
Source File: GUILabelingTool.java    From Pixie with MIT License 5 votes vote down vote up
/**
 * Handling of keyboard events when Alt key is pressed.
 *
 * @param key the key code
 */
private void handleAltKey(int key) {
    switch (key) {
        case KeyEvent.VK_A:
            // increase left
            gc.changeSizeSelection(-1, 0, 0, 0);
            break;

        case KeyEvent.VK_W:
            // increase top
            gc.changeSizeSelection(0, -1, 0, 0);
            break;

        case KeyEvent.VK_D:
            // increase right
            gc.changeSizeSelection(0, 0, 1, 0);
            break;

        case KeyEvent.VK_S:
            // increase bottom
            gc.changeSizeSelection(0, 0, 0, 1);
            break;

        case KeyEvent.VK_Z:
            // decrease box
            gc.changeSizeSelection(1, 1, -1, -1);
            break;

        case KeyEvent.VK_X:
            // increase box
            gc.changeSizeSelection(-1, -1, 1, 1);
            break;

        default:
            // do nothing
            break;
    }
}
 
Example 8
Source File: GUILabelingTool.java    From Pixie with MIT License 5 votes vote down vote up
/**
 * Handling of the keyboard events when Control key is pressed.
 *
 * @param key the key code
 */
private void handleCtrlKey(int key) {
    switch (key) {
        case KeyEvent.VK_PLUS:
            log.info("Key pressed: Ctrl NumPad+ =  Zoom in");
            break;

        case KeyEvent.VK_MINUS:
            log.info("Key pressed: Ctrl NumPad- =  Zoom out");
            break;

        case KeyEvent.VK_A:
            // decrease left
            gc.changeSizeSelection(1, 0, 0, 0);
            break;

        case KeyEvent.VK_W:
            // decrease top
            gc.changeSizeSelection(0, 1, 0, 0);
            break;

        case KeyEvent.VK_D:
            // decrease right
            gc.changeSizeSelection(0, 0, -1, 0);
            break;

        case KeyEvent.VK_S:
            // decrease bottom
            gc.changeSizeSelection(0, 0, 0, -1);
            break;

        default:
            // do nothing
            break;
    }
}
 
Example 9
Source File: BoundingBoxWindow.java    From Pixie with MIT License 5 votes vote down vote up
/**
 * Handle the keyboard events.
 *
 * @param key the key code
 */
private void handleNormalKey(int key) {
    switch (key) {
        case KeyEvent.VK_DELETE:
            deleteObject();
            break;

        case KeyEvent.VK_A:
            // move the box to the left                            
            moveObject(-1, 0);
            break;

        case KeyEvent.VK_D:
            // move the box to the right
            moveObject(1, 0);
            break;

        case KeyEvent.VK_W:
            // move the box up
            moveObject(0, -1);
            break;

        case KeyEvent.VK_S:
            // move the box down
            moveObject(0, 1);
            break;

        default:
            // do nothing
            break;
    }
}
 
Example 10
Source File: ShortcutListener.java    From jeddict with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    super.keyPressed(e);
    if (e.isControlDown() == true) {
        if (e.getKeyCode() == KeyEvent.VK_G) {
            JPAModelerUtil.generateSourceCode(file);
        } else if (e.getKeyCode() == KeyEvent.VK_D) {
            DBUtil.openDBModeler(file);
        } else if (e.getKeyCode() == KeyEvent.VK_B) {
            JSONBUtil.openJSONBViewer(file);
        }
    }
}
 
Example 11
Source File: BoundingBoxWindow.java    From Pixie with MIT License 5 votes vote down vote up
/**
 * Handle the keyboard events when Control key is pressed.
 *
 * @param key the key code
 */
private void handleCtrlKey(int key) {
    switch (key) {
        case KeyEvent.VK_A:
            // decrease left
            changeSize(1, 0, 0, 0);
            break;

        case KeyEvent.VK_W:
            // decrease top
            changeSize(0, 1, 0, 0);
            break;

        case KeyEvent.VK_D:
            // decrease right
            changeSize(0, 0, -1, 0);
            break;

        case KeyEvent.VK_S:
            // decrease bottom
            changeSize(0, 0, 0, -1);
            break;

        default:
            // do nothing
            break;
    }
}
 
Example 12
Source File: Polyline.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
   public void keyPressed(final KeyEvent ke) {
	final int keyCode = ke.getKeyCode();
	switch (keyCode) {
		case KeyEvent.VK_D:
			if (-1 == last_autotrace_start) {
				if (0 > n_points) Utils.log("Cannot remove last set of autotraced points:\n  Manual editions exist, or never autotraced.");
				return;
			}
			// Else, remove:
			final int len = n_points - last_autotrace_start;
			n_points = last_autotrace_start;
			last_autotrace_start = -1;
			repaint(true, null);
			// update buckets for layers of all points from n_points to last_autotrace_start
			final HashSet<Long> hs = new HashSet<Long>();
			for (int i = n_points+1; i < n_points+len; i++) hs.add(p_layer[i]);
			for (final Long l : hs) updateBucket(layer_set.getLayer(l.longValue()));
			Utils.log("Removed " + len + " autotraced points.");
			return;
		case KeyEvent.VK_R: // reset tracing
			tr_map.remove(layer_set);
			ke.consume();
			Utils.log("Reset tracing data for Polyline " + this);
			return;
	}
}
 
Example 13
Source File: KeyRemappingConfig.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@ConfigItem(
	position = 5,
	keyName = "right",
	name = "Camera Right key",
	description = "The key which will replace right."
)
default ModifierlessKeybind right()
{
	return new ModifierlessKeybind(KeyEvent.VK_D, 0);
}
 
Example 14
Source File: AbstractBlock.java    From JavaGame with MIT License 5 votes vote down vote up
/**
 * ���̰����¼�
 * 
 * @param e
 */
public void keyPressed(KeyEvent e) {
	switch (e.getKeyCode()) {
	case KeyEvent.VK_UP:
	case KeyEvent.VK_W:
		direction = Direction.ROTATE;
		break;
	case KeyEvent.VK_DOWN:
	case KeyEvent.VK_S:
		direction = Direction.DOWN;
		break;
	case KeyEvent.VK_LEFT:
	case KeyEvent.VK_A:
		if (x <= Constant.GAME_X_LEFT) {// ��߽�
			direction = Direction.NORMAL;
		} else {
			direction = Direction.LEFT;
		}
		break;
	case KeyEvent.VK_RIGHT:
	case KeyEvent.VK_D:
		if (maxX >= Constant.GAME_X_RIGHT - Constant.BLOCK_WIDTH / 2) {// �ұ߽�
			direction = Direction.NORMAL;
		} else {
			direction = Direction.RIGHT;
		}
		break;
	}
}
 
Example 15
Source File: ConstructionWizard.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Sets the new x and y location and facing of the site
 * @param s
 * @param c
 */
public void processKeyPress(ConstructionSite s, int c) {
	int facing = (int) s.getFacing();
	double x = s.getXLocation();
	double y = s.getYLocation();

    if (c == KeyEvent.VK_UP // 38
    	|| c == KeyEvent.VK_KP_UP
    	|| c == KeyEvent.VK_W
    	|| c == KeyEvent.VK_NUMPAD8) {
    	upKeyPressed = true;
    } else if(c == KeyEvent.VK_DOWN // 40
    	|| c == KeyEvent.VK_KP_DOWN
    	|| c == KeyEvent.VK_S
    	|| c == KeyEvent.VK_NUMPAD2) {
    	downKeyPressed = true;
    } else if(c == KeyEvent.VK_LEFT // 37
    	|| c == KeyEvent.VK_KP_LEFT
    	|| c == KeyEvent.VK_A
    	|| c == KeyEvent.VK_NUMPAD4) {
    	leftKeyPressed = true;
    } else if(c == KeyEvent.VK_RIGHT // 39
    	|| c == KeyEvent.VK_KP_RIGHT
    	|| c == KeyEvent.VK_D
    	|| c == KeyEvent.VK_NUMPAD6) {
    	rightKeyPressed = true;
    } else if(c == KeyEvent.VK_R
    	|| c == KeyEvent.VK_F) {
    	turnKeyPressed = true;
    }
    	
   	double w0 = s.getWidth();
	double l0 = s.getLength();
	double f0 = s.getFacing();
	
	BoundedObject b0 = null;
	
    if (upKeyPressed) {
    	b0 = new BoundedObject(s.getXLocation(), s.getYLocation() + 3, w0, l0, f0);
    	if (!isCollided(b0))
    		s.setYLocation(y + 1);	
    }
    
    if (downKeyPressed) {
    	b0 = new BoundedObject(s.getXLocation(), s.getYLocation() - 3, w0, l0, f0);
    	if (!isCollided(b0)) 
    		s.setYLocation(y - 1);
    }
    
    if (leftKeyPressed) {
    	b0 = new BoundedObject(s.getXLocation() + 3, s.getYLocation(), w0, l0, f0);
    	if (!isCollided(b0)) 
    		s.setXLocation(x + 1);
    }
    
    if (rightKeyPressed) {
    	b0 = new BoundedObject(s.getXLocation() - 3, s.getYLocation(), w0, l0, f0);
    	if (!isCollided(b0)) 
    		s.setXLocation(x - 1);
    }
    
   	if (turnKeyPressed) {
    	facing = facing + 45;
    	if (facing >= 360)
    		facing = facing - 360;
    	b0 = new BoundedObject(s.getXLocation(), s.getYLocation(), w0, l0, facing);
   		if (!isCollided(b0)) {    	
	    	s.setFacing(facing);
   		}
    }
    
}
 
Example 16
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static String getLowerCaseAlphaChar(int code) {
	switch (code) {
	case KeyEvent.VK_Q:
		return "q";
	case KeyEvent.VK_W:
		return "w";
	case KeyEvent.VK_E:
		return "e";
	case KeyEvent.VK_R:
		return "r";
	case KeyEvent.VK_T:
		return "t";
	case KeyEvent.VK_Y:
		return "y";
	case KeyEvent.VK_U:
		return "u";
	case KeyEvent.VK_I:
		return "i";
	case KeyEvent.VK_O:
		return "o";
	case KeyEvent.VK_P:
		return "p";
	case KeyEvent.VK_A:
		return "a";
	case KeyEvent.VK_S:
		return "s";
	case KeyEvent.VK_D:
		return "d";
	case KeyEvent.VK_F:
		return "f";
	case KeyEvent.VK_G:
		return "g";
	case KeyEvent.VK_H:
		return "h";
	case KeyEvent.VK_J:
		return "j";
	case KeyEvent.VK_K:
		return "k";
	case KeyEvent.VK_L:
		return "l";
	case KeyEvent.VK_Z:
		return "z";
	case KeyEvent.VK_X:
		return "x";
	case KeyEvent.VK_C:
		return "c";
	case KeyEvent.VK_V:
		return "v";
	case KeyEvent.VK_B:
		return "b";
	case KeyEvent.VK_N:
		return "n";
	case KeyEvent.VK_M:
		return "m";
	default:
		return "";
	}
}
 
Example 17
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static String getUpperCaseAlphaChar(int code) {
	switch (code) {
	case KeyEvent.VK_Q:
		return "Q";
	case KeyEvent.VK_W:
		return "W";
	case KeyEvent.VK_E:
		return "E";
	case KeyEvent.VK_R:
		return "R";
	case KeyEvent.VK_T:
		return "T";
	case KeyEvent.VK_Y:
		return "Y";
	case KeyEvent.VK_U:
		return "U";
	case KeyEvent.VK_I:
		return "I";
	case KeyEvent.VK_O:
		return "O";
	case KeyEvent.VK_P:
		return "P";
	case KeyEvent.VK_A:
		return "A";
	case KeyEvent.VK_S:
		return "S";
	case KeyEvent.VK_D:
		return "D";
	case KeyEvent.VK_F:
		return "F";
	case KeyEvent.VK_G:
		return "G";
	case KeyEvent.VK_H:
		return "H";
	case KeyEvent.VK_J:
		return "J";
	case KeyEvent.VK_K:
		return "K";
	case KeyEvent.VK_L:
		return "L";
	case KeyEvent.VK_Z:
		return "Z";
	case KeyEvent.VK_X:
		return "X";
	case KeyEvent.VK_C:
		return "C";
	case KeyEvent.VK_V:
		return "V";
	case KeyEvent.VK_B:
		return "B";
	case KeyEvent.VK_N:
		return "N";
	case KeyEvent.VK_M:
		return "M";
	default:
		return "";
	}
}
 
Example 18
Source File: KeyManager.java    From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public void tick(){
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
}
 
Example 19
Source File: KeyManager.java    From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public void tick(){
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
}
 
Example 20
Source File: KeyManager.java    From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public void tick(){
	up = keys[KeyEvent.VK_W];
	down = keys[KeyEvent.VK_S];
	left = keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_D];
}