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

The following examples show how to use java.awt.event.KeyEvent#VK_NUMPAD6 . 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: KeyCodeToChar.java    From Repeat with Apache License 2.0 5 votes vote down vote up
private static String getCharFromNumpadCode(int code, KeyboardState state) {
	if (!state.isNumslockLocked()) {
		return "";
	}

	switch (code) {
		case KeyEvent.VK_NUMPAD0:
			return "0";
		case KeyEvent.VK_NUMPAD1:
			return "1";
		case KeyEvent.VK_NUMPAD2:
			return "2";
		case KeyEvent.VK_NUMPAD3:
			return "3";
		case KeyEvent.VK_NUMPAD4:
			return "4";
		case KeyEvent.VK_NUMPAD5:
			return "5";
		case KeyEvent.VK_NUMPAD6:
			return "6";
		case KeyEvent.VK_NUMPAD7:
			return "7";
		case KeyEvent.VK_NUMPAD8:
			return "8";
		case KeyEvent.VK_NUMPAD9:
			return "9";
		case KeyEvent.VK_PLUS:
			return "+";
		case KeyEvent.VK_MULTIPLY:
			return "*";
		default:
			return "";
	}
}
 
Example 2
Source File: ConstructionWizard.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the new x and y location and facing of the site
 * @param c
 */
public void processKeyRelease(int c) {

    if (c == KeyEvent.VK_UP // 38
	    	|| c == KeyEvent.VK_KP_UP
	    	|| c == KeyEvent.VK_W
	    	|| c == KeyEvent.VK_NUMPAD8) {
	    	upKeyPressed = false;
	    } else if(c == KeyEvent.VK_DOWN // 40
	    	|| c == KeyEvent.VK_KP_DOWN
	    	|| c == KeyEvent.VK_S
	    	|| c == KeyEvent.VK_NUMPAD2) {
	    	downKeyPressed = false;
	    } else if(c == KeyEvent.VK_LEFT // 37
	    	|| c == KeyEvent.VK_KP_LEFT
	    	|| c == KeyEvent.VK_A
	    	|| c == KeyEvent.VK_NUMPAD4) {
	    	leftKeyPressed = false;
	    } else if(c == KeyEvent.VK_RIGHT // 39
	    	|| c == KeyEvent.VK_KP_RIGHT
	    	|| c == KeyEvent.VK_D
	    	|| c == KeyEvent.VK_NUMPAD6) {
	    	rightKeyPressed = false;
	    } else if(c == KeyEvent.VK_R
	    	|| c == KeyEvent.VK_F) {
	    	turnKeyPressed = false;
	    }

}
 
Example 3
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 4
Source File: MacKeymapUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static String getKeyText(int code) {
  switch (code) {
    case KeyEvent.VK_BACK_SPACE:     return BACKSPACE;
    case KeyEvent.VK_ESCAPE:         return ESCAPE;
    case KeyEvent.VK_CAPS_LOCK:      return CAPS_LOCK;
    case KeyEvent.VK_TAB:            return TAB;
    case KeyEvent.VK_SPACE:          return SPACE;
    case KeyEvent.VK_DELETE:         return DELETE;
    case KeyEvent.VK_HOME:           return HOME;
    case KeyEvent.VK_END:            return END;
    case KeyEvent.VK_PAGE_UP:        return PAGE_UP;
    case KeyEvent.VK_PAGE_DOWN:      return PAGE_DOWN;
    case KeyEvent.VK_UP:             return UP;
    case KeyEvent.VK_DOWN:           return DOWN;
    case KeyEvent.VK_LEFT:           return LEFT;
    case KeyEvent.VK_RIGHT:          return RIGHT;
    case KeyEvent.VK_NUM_LOCK:       return NUMBER_LOCK;
    case KeyEvent.VK_ENTER:          return RETURN;
    case KeyEvent.VK_BACK_QUOTE:     return "`";
    case KeyEvent.VK_NUMBER_SIGN:    return NUM_PAD;
    case KeyEvent.VK_MULTIPLY:       return NUM_PAD + " *";
    case KeyEvent.VK_ADD:            return "+";
    case KeyEvent.VK_SEPARATOR:      return ",";
    case KeyEvent.VK_SUBTRACT:       return "-";
    case KeyEvent.VK_DECIMAL:        return ".";
    case KeyEvent.VK_DIVIDE:         return "/";
    case KeyEvent.VK_NUMPAD0:        return "0";
    case KeyEvent.VK_NUMPAD1:        return "1";
    case KeyEvent.VK_NUMPAD2:        return "2";
    case KeyEvent.VK_NUMPAD3:        return "3";
    case KeyEvent.VK_NUMPAD4:        return "4";
    case KeyEvent.VK_NUMPAD5:        return "5";
    case KeyEvent.VK_NUMPAD6:        return "6";
    case KeyEvent.VK_NUMPAD7:        return "7";
    case KeyEvent.VK_NUMPAD8:        return "8";
    case KeyEvent.VK_NUMPAD9:        return "9";
    case KeyEvent.VK_SLASH:          return "/";
    case KeyEvent.VK_BACK_SLASH:     return "\\";
    case KeyEvent.VK_PERIOD:         return ".";
    case KeyEvent.VK_SEMICOLON:      return ";";
    case KeyEvent.VK_CLOSE_BRACKET:  return "]";
    case KeyEvent.VK_OPEN_BRACKET:   return "[";
    case KeyEvent.VK_EQUALS:         return "=";
    case KeyEvent.VK_MINUS:          return "-";
    case KeyEvent.VK_PLUS:           return "+";
    case 0:                          return "fn";
  }
  return KeyEvent.getKeyText(code);
}