Java Code Examples for org.lwjgl.input.Keyboard#KEY_DOWN
The following examples show how to use
org.lwjgl.input.Keyboard#KEY_DOWN .
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: Example2_2.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void keyReleased(int key, char c) { switch(key) { case Keyboard.KEY_UP: dy = 0; break; case Keyboard.KEY_DOWN: dy = 0; break; case Keyboard.KEY_LEFT: dx = 0; break; case Keyboard.KEY_RIGHT: dx = 0; break; } }
Example 2
Source File: Example2_2.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void keyPressed(int key, char c) { switch(key) { case Keyboard.KEY_UP: dy = stepSize; break; case Keyboard.KEY_DOWN: dy = -stepSize; break; case Keyboard.KEY_LEFT: dx = -stepSize; break; case Keyboard.KEY_RIGHT: dx = stepSize; break; } }
Example 3
Source File: GuiEditNBTTree.java From NBTEdit with GNU General Public License v3.0 | 6 votes |
protected void keyTyped(char par1, int key) { GuiEditNBT window = guiTree.getWindow(); if (window != null) window.keyTyped(par1, key); else{ if (key == 1){ if (guiTree.isEditingSlot()) guiTree.stopEditingSlot(); else quitWithoutSaving(); } else if (key == Keyboard.KEY_DELETE) guiTree.deleteSelected(); else if (key == Keyboard.KEY_RETURN) guiTree.editSelected(); else if (key == Keyboard.KEY_UP) guiTree.arrowKeyPressed(true); else if (key == Keyboard.KEY_DOWN) guiTree.arrowKeyPressed(false); else guiTree.keyTyped(par1, key); } }
Example 4
Source File: Menu.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
protected final void keyRepeat(KeyboardEvent event) { switch (event.getKeyCode()) { case Keyboard.KEY_TAB: switchFocus(event.isShiftDown() ? -1 : 1); break; case Keyboard.KEY_UP: focusPrior(); break; case Keyboard.KEY_DOWN: focusNext(); break; default: break; } }
Example 5
Source File: GuiScrollSlot.java From CodeChickenCore with MIT License | 5 votes |
@Override public void keyTyped(char c, int keycode) { if (!focused) return; if (keycode == Keyboard.KEY_UP) selectPrev(); if (keycode == Keyboard.KEY_DOWN) selectNext(); if (keycode == Keyboard.KEY_RETURN && actionCommand != null) sendAction(actionCommand); }
Example 6
Source File: ScrollBar.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public final void keyRepeat(KeyboardEvent event) { switch (event.getKeyCode()) { case Keyboard.KEY_UP: owner.setOffsetY(owner.getOffsetY() - owner.getStepHeight()); scroll_button.setupPos(ScrollBar.this); break; case Keyboard.KEY_DOWN: owner.setOffsetY(owner.getOffsetY() + owner.getStepHeight()); scroll_button.setupPos(ScrollBar.this); break; default: break; } }
Example 7
Source File: PulldownMenu.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
protected final void keyRepeat(KeyboardEvent event) { switch (event.getKeyCode()) { case Keyboard.KEY_UP: focusPrior(); break; case Keyboard.KEY_DOWN: focusNext(); break; default: super.keyRepeat(event); break; } }
Example 8
Source File: LocationEditGui.java From SkyblockAddons with MIT License | 5 votes |
/** * Allow moving the last hovered feature with arrow keys. */ @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); Feature hoveredFeature = ButtonLocation.getLastHoveredFeature(); if (hoveredFeature != null) { int xOffset = 0; int yOffset = 0; if (keyCode == Keyboard.KEY_LEFT) { xOffset--; } else if (keyCode == Keyboard.KEY_UP) { yOffset--; } else if (keyCode == Keyboard.KEY_RIGHT) { xOffset++; } else if (keyCode == Keyboard.KEY_DOWN) { yOffset++; } if (keyCode == Keyboard.KEY_A) { xOffset-= 10; } else if (keyCode == Keyboard.KEY_W) { yOffset-= 10; } else if (keyCode == Keyboard.KEY_D) { xOffset+= 10; } else if (keyCode == Keyboard.KEY_S) { yOffset+= 10; } main.getConfigValues().setCoords(hoveredFeature, main.getConfigValues().getRelativeCoords(hoveredFeature).getX()+xOffset, main.getConfigValues().getRelativeCoords(hoveredFeature).getY()+yOffset); } }
Example 9
Source File: GameCamera.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
private final boolean scrollSpeedLocked(int key) { return scroll_x != 0 || scroll_y != 0 || (LocalInput.isKeyDown(Keyboard.KEY_UP) && key != Keyboard.KEY_UP) || (LocalInput.isKeyDown(Keyboard.KEY_DOWN) && key != Keyboard.KEY_DOWN) || (LocalInput.isKeyDown(Keyboard.KEY_LEFT) && key != Keyboard.KEY_LEFT) || (LocalInput.isKeyDown(Keyboard.KEY_RIGHT) && key != Keyboard.KEY_RIGHT); }
Example 10
Source File: LwjglKeyboardHandleModule.java From tprogers2048game with GNU General Public License v3.0 | 5 votes |
/** * Считывание последних данных из стека событий */ @Override public void update() { resetValues(); lastDirectionKeyPressed = Direction.AWAITING; while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { switch(Keyboard.getEventKey()){ case Keyboard.KEY_ESCAPE: wasEscPressed = true; break; case Keyboard.KEY_UP: lastDirectionKeyPressed = Direction.UP; break; case Keyboard.KEY_RIGHT: lastDirectionKeyPressed = Direction.RIGHT; break; case Keyboard.KEY_DOWN: lastDirectionKeyPressed = Direction.DOWN; break; case Keyboard.KEY_LEFT: lastDirectionKeyPressed = Direction.LEFT; break; } } } }
Example 11
Source File: TabGui.java From ClientBase with MIT License | 5 votes |
public void handleKey(int keycode) { if (keycode == Keyboard.KEY_DOWN) { if (selectedSubTab == -1) { selectedTab++; if (selectedTab >= tabs.size()) { selectedTab = 0; } } else { selectedSubTab++; if (selectedSubTab >= tabs.get(selectedTab).getSubTabs().size()) { selectedSubTab = 0; } } } else if (keycode == Keyboard.KEY_UP) { if (selectedSubTab == -1) { selectedTab--; if (selectedTab < 0) { selectedTab = tabs.size() - 1; } } else { selectedSubTab--; if (selectedSubTab < 0) { selectedSubTab = tabs.get(selectedTab).getSubTabs().size() - 1; } } } else if (keycode == Keyboard.KEY_LEFT) { selectedSubTab = -1; } else if (selectedSubTab == -1 && (keycode == Keyboard.KEY_RETURN || keycode == Keyboard.KEY_RIGHT)) { selectedSubTab = 0; } else if (keycode == Keyboard.KEY_RETURN || keycode == Keyboard.KEY_RIGHT) { tabs.get(selectedTab).getSubTabs().get(selectedSubTab).press(); } }
Example 12
Source File: GameCamera.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
public final void keyPressed(KeyboardEvent event) { switch (event.getKeyCode()) { case Keyboard.KEY_HOME: case Keyboard.KEY_NUMPAD8: break; case Keyboard.KEY_END: case Keyboard.KEY_NUMPAD2: break; case Keyboard.KEY_INSERT: case Keyboard.KEY_NUMPAD6: viewer.getPicker().pickRotate(this); break; case Keyboard.KEY_DELETE: case Keyboard.KEY_NUMPAD4: viewer.getPicker().pickRotate(this); break; case Keyboard.KEY_PRIOR: case Keyboard.KEY_NUMPAD9: mouseScrolled(-2); break; case Keyboard.KEY_NEXT: case Keyboard.KEY_NUMPAD3: mouseScrolled(2); break; case Keyboard.KEY_UP: if (!scrollSpeedLocked(Keyboard.KEY_UP)) { scroll_acceleration_seconds = 0; setScrollSpeed(); } break; case Keyboard.KEY_DOWN: if (!scrollSpeedLocked(Keyboard.KEY_DOWN)) { scroll_acceleration_seconds = 0; setScrollSpeed(); } break; case Keyboard.KEY_LEFT: if (!scrollSpeedLocked(Keyboard.KEY_LEFT)) { scroll_acceleration_seconds = 0; setScrollSpeed(); } break; case Keyboard.KEY_RIGHT: if (!scrollSpeedLocked(Keyboard.KEY_RIGHT)) { scroll_acceleration_seconds = 0; setScrollSpeed(); } break; } }
Example 13
Source File: EditBox.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
protected final void keyRepeat(KeyboardEvent event) { //char ch = event.getKeyChar(); Box edit_box = Skin.getSkin().getEditBox(); switch (event.getKeyCode()) { case Keyboard.KEY_RETURN: if (insert(index, '\n')) { index++; } break; case Keyboard.KEY_BACK: if (index > 0) delete(--index); break; case Keyboard.KEY_DELETE: if (index < getText().length()) delete(index); break; case Keyboard.KEY_LEFT: if (index > 0) index--; break; case Keyboard.KEY_RIGHT: if (index < getText().length()) index++; break; case Keyboard.KEY_UP: index = getTextRenderer().jump(edit_box.getLeftOffset(), edit_box.getBottomOffset(), 0, getFont().getHeight(), getText(), index); break; case Keyboard.KEY_DOWN: index = getTextRenderer().jump(edit_box.getLeftOffset(), edit_box.getBottomOffset(), 0, -getFont().getHeight(), getText(), index); break; case Keyboard.KEY_HOME: index = getTextRenderer().jump(edit_box.getLeftOffset(), edit_box.getBottomOffset(), -getWidth(), 0, getText(), index); break; case Keyboard.KEY_END: index = getTextRenderer().jump(edit_box.getLeftOffset(), edit_box.getBottomOffset(), getWidth(), 0, getText(), index); break; case Keyboard.KEY_TAB: case Keyboard.KEY_ESCAPE: super.keyRepeat(event); break; default: char key = event.getKeyChar(); if (getFont().getQuad(key) != null) { if (insert(index, key)) index++; } else { super.keyRepeat(event); } break; } correctOffsetY(); }
Example 14
Source File: GuiOreMappingSatellite.java From AdvancedRocketry with MIT License | 4 votes |
@Override protected void keyTyped(char c, int i) throws IOException { if(i == Keyboard.KEY_W) { zCenter -= radius; runMapperWithSelection(); } else if(i == Keyboard.KEY_S) { zCenter += radius; runMapperWithSelection(); } else if(i == Keyboard.KEY_A) { xCenter -= radius; runMapperWithSelection(); } else if(i == Keyboard.KEY_D) { xCenter += radius; runMapperWithSelection(); } else if(i == Keyboard.KEY_DOWN){ scanSize = Math.min(scanSize*2, maxZoom); runMapperWithSelection(); } else if(i == Keyboard.KEY_UP) { if((scanSize/2)/radius > 0) { scanSize = Math.max(scanSize/2, 2); runMapperWithSelection(); } } //TODO: fix radius /*else if(i == Keyboard.KEY_LEFT) { radius = Math.max(radius / 2, 1); currentMapping.interrupt(); resetTexture(); currentMapping = new Thread(mapper); currentMapping.start(); } else if(i == Keyboard.KEY_RIGHT) { if(scanSize/(radius*2) > 0) { radius = Math.min(radius*2, MAXRADIUS); currentMapping.interrupt(); resetTexture(); currentMapping = new Thread(mapper); currentMapping.start(); } }*/ else super.keyTyped(c, i); }
Example 15
Source File: Options.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Checks if the given key is a valid game key. * @param key the keyboard key * @return {@code true} if valid, {@code false} otherwise */ private static boolean isValidGameKey(int key) { return (key != Keyboard.KEY_ESCAPE && key != Keyboard.KEY_SPACE && key != Keyboard.KEY_UP && key != Keyboard.KEY_DOWN && key != Keyboard.KEY_F7 && key != Keyboard.KEY_F10 && key != Keyboard.KEY_F12); }
Example 16
Source File: Utils.java From opsu-dance with GNU General Public License v3.0 | 4 votes |
public static boolean isValidGameKey(int key) { return (key != Keyboard.KEY_ESCAPE && key != Keyboard.KEY_SPACE && key != Keyboard.KEY_UP && key != Keyboard.KEY_DOWN && key != Keyboard.KEY_F7 && key != Keyboard.KEY_F10 && key != Keyboard.KEY_F12); }
Example 17
Source File: AbstractKey.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
/** * Get the name of the key being set for CustomKey * * @param keyCode opengl name of the key being pressed * @return the name of the key */ protected String getKeyOrMouseName(int keyCode) { if (keyCode < 0) { String openGLName = Mouse.getButtonName(keyCode + 100); if (openGLName != null) { if (openGLName.equalsIgnoreCase("button0")) return "LMB"; if (openGLName.equalsIgnoreCase("button1")) return "RMB"; } return openGLName; } if (mod.getSettings().isUsingLiteralKeys()) { switch (keyCode) { case Keyboard.KEY_GRAVE: return "~"; case Keyboard.KEY_MINUS: case Keyboard.KEY_SUBTRACT: return "-"; case Keyboard.KEY_APOSTROPHE: return "'"; case Keyboard.KEY_LBRACKET: return "["; case Keyboard.KEY_RBRACKET: return "]"; case Keyboard.KEY_BACKSLASH: return "\\"; case Keyboard.KEY_DIVIDE: case Keyboard.KEY_SLASH: return "/"; case Keyboard.KEY_COMMA: return ","; case Keyboard.KEY_PERIOD: return "."; case Keyboard.KEY_SEMICOLON: return ";"; case Keyboard.KEY_EQUALS: return "="; case Keyboard.KEY_UP: return "▲"; case Keyboard.KEY_DOWN: return "▼"; case Keyboard.KEY_LEFT: return "◀"; case Keyboard.KEY_RIGHT: return "▶"; case Keyboard.KEY_MULTIPLY: return "*"; case Keyboard.KEY_ADD: return "+"; } } return Keyboard.getKeyName(keyCode); }