Java Code Examples for processing.event.KeyEvent#RELEASE

The following examples show how to use processing.event.KeyEvent#RELEASE . 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: SavedPointUI.java    From haxademic with MIT License 6 votes vote down vote up
public void keyEvent(KeyEvent e) {
	if(active == false) return;
	if(e.getAction() == KeyEvent.PRESS) {
		// shift
		if(e.getKeyCode() == P.SHIFT) shiftDown = true;
		// reset timeout
		if(e.getKeyCode() == P.UP || e.getKeyCode() == P.LEFT || e.getKeyCode() == P.RIGHT || e.getKeyCode() == P.DOWN) resetInteractionTimeout();
		// translate if arrow key
		Point translatePoint = new Point(0, 0);
		if(e.getKeyCode() == P.UP) translatePoint.setLocation(0, -1);
		if(e.getKeyCode() == P.LEFT) translatePoint.setLocation(-1, 0);
		if(e.getKeyCode() == P.RIGHT) translatePoint.setLocation(1, 0);
		if(e.getKeyCode() == P.DOWN) translatePoint.setLocation(0, 1);
		if(shiftDown) { translatePoint.x *= 10; translatePoint.y *= 10; }
		// apply transformation if needed
		if(translatePoint.x != 0 || translatePoint.y != 0) {
			position.add(translatePoint.x, translatePoint.y);
			save();
		}
	}
	if(e.getAction() == KeyEvent.RELEASE) {
		if(e.getKeyCode() == P.SHIFT) shiftDown = false;
	}
}
 
Example 2
Source File: PScene.java    From Project-16x16 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method is <b>Public</b> only to enable binding to a parent PApplet.
 * <p>
 * You can <b>ignore this method</b> since the parent sketch will call it
 * automatically when it detects a key event (provided register() has been
 * called).
 */
public final void keyEvent(KeyEvent e) {
	switch (e.getAction()) {
		case KeyEvent.PRESS :
			keyPressed(e);
			break;
		case KeyEvent.RELEASE :
			keyReleased(e);
			break;
		default :
			break;
	}
}
 
Example 3
Source File: BaseSavedQuadUI.java    From haxademic with MIT License 5 votes vote down vote up
public void keyEvent(KeyEvent e) {
	if(active == false) return;
	if(e.getAction() == KeyEvent.PRESS) {
		// shift
		if(e.getKeyCode() == P.SHIFT) shiftDown = true;
		// reset timeout
		if(e.getKeyCode() == P.UP || e.getKeyCode() == P.LEFT || e.getKeyCode() == P.RIGHT || e.getKeyCode() == P.DOWN || e.getKeyCode() == P.TAB) resetInteractionTimeout();
		// translate if arrow key
		Point translatePoint = new Point(0, 0);
		if(e.getKeyCode() == P.UP) translatePoint.setLocation(0, -1);
		if(e.getKeyCode() == P.LEFT) translatePoint.setLocation(-1, 0);
		if(e.getKeyCode() == P.RIGHT) translatePoint.setLocation(1, 0);
		if(e.getKeyCode() == P.DOWN) translatePoint.setLocation(0, 1);
		if(shiftDown) { translatePoint.x *= 10; translatePoint.y *= 10; }
		// tab to next point
		if(e.getKeyCode() == P.TAB) {
			if(SELECTED_POINT == points[0]) SELECTED_POINT = points[1];
			else if(SELECTED_POINT == points[1]) SELECTED_POINT = points[2];
			else if(SELECTED_POINT == points[2]) SELECTED_POINT = points[3];
			else SELECTED_POINT = points[0];
			resetInteractionTimeout();
		}
		// apply transformation if needed
		if(translatePoint.x != 0 || translatePoint.y != 0) {
			if(SELECTED_POINT == points[0] || SELECTED_POINT == points[1] || SELECTED_POINT == points[2] || SELECTED_POINT == points[3]) {
				SELECTED_POINT.translate(translatePoint.x, translatePoint.y);
				save();
			} else if(DRAGGING_QUAD == this) {
				for( int i=0; i < points.length; i++ ) {
					points[i].translate(translatePoint.x, translatePoint.y);
				}
				save();
			}
		}
		updateCenter();
	}
	if(e.getAction() == KeyEvent.RELEASE) {
		if(e.getKeyCode() == P.SHIFT) shiftDown = false;
	}
}
 
Example 4
Source File: KeyboardState.java    From haxademic with MIT License 5 votes vote down vote up
public void keyEvent(KeyEvent e) {
	if(e.getAction() == KeyEvent.PRESS) {
		setKeyOn(e.getKeyCode());
	}
	if(e.getAction() == KeyEvent.RELEASE) {
		setKeyOff(e.getKeyCode());
	}
}