Java Code Examples for processing.event.KeyEvent#PRESS
The following examples show how to use
processing.event.KeyEvent#PRESS .
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 |
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: DMXEditor.java From haxademic with MIT License | 6 votes |
public void keyEvent(KeyEvent e) { if(e.getAction() == KeyEvent.PRESS) { if(e.getKey() == ']') { pointIndex++; if(pointIndex >= points.size()) pointIndex = 0; setActivePoint(); } if(e.getKey() == '[') { pointIndex--; if(pointIndex < 0) pointIndex = points.size() - 1; setActivePoint(); } if(e.getKey() == 's') saveLightsToFile(); if(e.getKeyCode() == 147) deleteActiveLight(); if(e.getKeyCode() == '`') showInfo = !showInfo; } }
Example 3
Source File: UITextInput.java From haxademic with MIT License | 6 votes |
public void keyEvent(KeyEvent e) { if(active == false) return; if(ACTIVE_INPUT != this) return; if(e.getAction() == KeyEvent.PRESS) { char key = e.getKey(); int keyCode = e.getKeyCode(); // P.out(keyCode, PConstants.SHIFT); if(key == PConstants.BACKSPACE) { if(value.length() > 0) { value = value.substring( 0, value.length() - 1 ); } } else if(key == PConstants.RETURN || key == PConstants.ENTER || keyCode == PConstants.SHIFT || key == PConstants.TAB) { // do nothing for special keys } else { value += key; if(filter != null) value = value.replaceAll(filter, ""); } } }
Example 4
Source File: PScene.java From Project-16x16 with GNU General Public License v3.0 | 5 votes |
/** * 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 5
Source File: PaperScreen.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
/** * Events coming from Processing to handle keys. * * @param e */ public void keyEvent(KeyEvent e) { String filename = "paper-" + Integer.toString(id) + ".xml"; if (e.isAltDown() || !useAlt) { if (e.getAction() == KeyEvent.PRESS) { if (saveName == null) { System.err.println("This paperscreen does not have name ! \n Set it with setSaveName()"); } else { filename = saveName; } if (saveKey != null && (e.getKey() == saveKey.charAt(0))) { System.out.println("Saved to : " + filename); this.saveLocationTo(filename); } if (trackKey != null && (e.getKey() == trackKey.charAt(0))) { this.useManualLocation(!this.useManualLocation, null); String status = useManualLocation ? "ON" : "OFF"; System.out.println("PaperScreen: " + filename + " tracking: " + status); } if (loadKey != null && (e.getKey() == loadKey.charAt(0))) { this.loadLocationFrom(filename); System.out.println("Loaded from: " + filename); } } } }
Example 6
Source File: BaseSavedQuadUI.java From haxademic with MIT License | 5 votes |
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 7
Source File: PGraphicsKeystone.java From haxademic with MIT License | 5 votes |
public void keyEvent(KeyEvent e) { super.keyEvent(e); if(active == false) return; if(offsetsX == null || offsetsY == null) return; if(e.getAction() == KeyEvent.PRESS) { // fine controls if(e.getKey() == 'Z') { selectedColIndex--; if(selectedColIndex < -1) selectedColIndex = offsetsX.length - 1; } if(e.getKey() == 'X') { selectedColIndex++; if(selectedColIndex >= offsetsX.length) selectedColIndex = -1; } if(e.getKey() == 'C') { selectedRowIndex--; if(selectedRowIndex < -1) selectedRowIndex = offsetsY.length - 1; } if(e.getKey() == 'V') { selectedRowIndex++; if(selectedRowIndex >= offsetsY.length) selectedRowIndex = -1; } if(e.getKey() == 'O') fineControlAdjust(offsetsX, selectedColIndex, -1f); if(e.getKey() == 'P') fineControlAdjust(offsetsX, selectedColIndex, 1f); if(e.getKey() == '{') fineControlAdjust(offsetsY, selectedRowIndex, -1f); if(e.getKey() == '}') fineControlAdjust(offsetsY, selectedRowIndex, 1f); if(e.getKey() == 'E') saveConfig(); } }
Example 8
Source File: KeyboardState.java From haxademic with MIT License | 5 votes |
public void keyEvent(KeyEvent e) { if(e.getAction() == KeyEvent.PRESS) { setKeyOn(e.getKeyCode()); } if(e.getAction() == KeyEvent.RELEASE) { setKeyOff(e.getKeyCode()); } }
Example 9
Source File: UISlider.java From haxademic with MIT License | 5 votes |
public void keyEvent(KeyEvent e) { if(isActive() == false) return; if(mouseHovered == false) return; if(e.getAction() == KeyEvent.PRESS) { if(e.getKeyCode() == P.LEFT) { value -= dragStep; value = P.max(value, valueMin); } if(e.getKeyCode() == P.RIGHT) { value += dragStep; value = P.min(value, valueMax); } if(saves) PrefToText.setValue(id, value); } }
Example 10
Source File: AudioIn.java From haxademic with MIT License | 5 votes |
public void keyEvent(KeyEvent e) { if(e.getAction() == KeyEvent.PRESS) { if(e.getKey() == ',') { audioInput.audioData().setGain(audioInput.audioData().gain() - 0.05f); DebugView.setValue("audioData.gain()", audioInput.audioData().gain()); } else if(e.getKey() == '.') { audioInput.audioData().setGain(audioInput.audioData().gain() + 0.05f); DebugView.setValue("audioData.gain()", audioInput.audioData().gain()); } } }