Java Code Examples for org.lwjgl.input.Keyboard#KEY_ESCAPE

The following examples show how to use org.lwjgl.input.Keyboard#KEY_ESCAPE . 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: GuiConfig.java    From CraftingKeys with MIT License 6 votes vote down vote up
@Override
public void keyTyped(char character, int keyCode) {

    if (keyCode == Keyboard.KEY_ESCAPE) {
        if (selectedButtonID != -1) {
            selectedButtonID = -1;
            drawKeyValues();
        } else {
            Logger.info("keyTyped(c,i)", "Trying to close inventory with esc.");

            try {
                super.keyTyped(character, keyCode); // Enable standard gui closing
            } catch (Exception ignored) {
                // support for newer versions, just do nothing
            }
        }

    } else if (selectedButtonID != -1) {
        if (!ArrayUtils.contains(keyValues, keyCode) || keyValues[selectedButtonID] == keyCode) { // No double keys
            keyValues[selectedButtonID] = keyCode;
            selectedButtonID = -1;
            drawKeyValues();
        }
    }

}
 
Example 2
Source File: GuiCapture.java    From OpenPeripheral-Addons with MIT License 6 votes vote down vote up
@Override
public void handleKeyboardInput() {
	final int key = Keyboard.getEventKey();

	if (key == Keyboard.KEY_ESCAPE) {
		this.mc.displayGuiScreen(null);
		this.mc.setIngameFocus();
	} else {
		final boolean state = Keyboard.getEventKeyState();
		if (state) {
			final char ch = sanitizeKeyChar(Keyboard.getEventCharacter());

			final boolean isRepeat = Keyboard.isRepeatEvent();
			new GlassesKeyDownEvent(guid, ch, key, isRepeat).sendToServer();
		} else {
			new GlassesKeyUpEvent(guid, key).sendToServer();
		}
	}

	// looks like twitch controls
	super.handleKeyboardInput();
}
 
Example 3
Source File: GuiDirectLogin.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    switch (keyCode) {
        case Keyboard.KEY_ESCAPE:
            mc.displayGuiScreen(prevGui);
            return;
        case Keyboard.KEY_TAB:
            TabUtils.tab(username, password);
            return;
        case Keyboard.KEY_RETURN:
            actionPerformed(loginButton);
            return;
    }

    if(username.isFocused())
        username.textboxKeyTyped(typedChar, keyCode);

    if(password.isFocused())
        password.textboxKeyTyped(typedChar, keyCode);
    super.keyTyped(typedChar, keyCode);
}
 
Example 4
Source File: GuiReactorControlRod.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
protected void keyTyped(char inputChar, int keyCode) {
       if (keyCode == Keyboard.KEY_ESCAPE ||
       		(!this.rodName.isFocused() && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())) {
           this.mc.thePlayer.closeScreen();
       }

	this.rodName.textboxKeyTyped(inputChar, keyCode);
	
	if(keyCode == Keyboard.KEY_TAB) {
		// Tab
		if(this.rodName.isFocused()) {
			this.rodName.setFocused(false);
		}
		else {
			this.rodName.setFocused(true);
		}
	}
	
	if(keyCode == Keyboard.KEY_RETURN) {
		// Return/enter
		this.actionPerformed((GuiButton)this.buttonList.get(2));
	}
}
 
Example 5
Source File: ComplexOpsuState.java    From opsu-dance with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void keyReleased(KeyEvent e)
{
	for (OverlayOpsuState overlay : overlays) {
		overlay.keyReleased(e);
		if (e.isConsumed()) {
			return;
		}
	}
	if (focusedComponent != null) {
		if (e.keyCode == Keyboard.KEY_ESCAPE) {
			focusedComponent.setFocused(false);
			focusedComponent = null;
		} else {
			focusedComponent.keyReleased(e);
		}
		e.consume();
	}
}
 
Example 6
Source File: InGameDelegate.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
protected void keyPressed(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_ESCAPE:
			getGUIRoot().pushDelegate(new InGameMainMenu(viewer, new StaticCamera(getCamera().getState()),
						viewer.getParameters()));
			break;
		default:
			if (!cheat(event))
				super.keyPressed(event);
			break;
	}
}
 
Example 7
Source File: DropdownMenu.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	if (e.keyCode == Keyboard.KEY_ESCAPE) {
		this.closeReleaseFocus();
		e.consume();
	}
}
 
Example 8
Source File: GuiHighlightTips.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void keyTyped(char c, int keycode) throws IOException {
    if (keycode == Keyboard.KEY_ESCAPE || keycode == Keyboard.KEY_BACK) {
        Minecraft.getMinecraft().displayGuiScreen(opt.slot.getGui());
        return;
    }
    super.keyTyped(c, keycode);
}
 
Example 9
Source File: ButtonMenu.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	if (e.keyCode == Keyboard.KEY_ESCAPE) {
		this.menuState.leave();
	} else {
		this.menuState.keyPressed(e);
	}
	e.consume();
}
 
Example 10
Source File: Splash.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	if (e.keyCode != Keyboard.KEY_ESCAPE) {
		return;
	}
	if (++escapeCount >= 3) {
		displayContainer.exitRequested = true;
	} else if (thread != null) {
		thread.interrupt();
	}
}
 
Example 11
Source File: GuiTerminalFluid.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@Override
protected void keyTyped(char key, int keyID)
{
	if (keyID == Keyboard.KEY_ESCAPE)
		mc.thePlayer.closeScreen();
	searchbar.textboxKeyTyped(key, keyID);
}
 
Example 12
Source File: GuiTextInput.java    From ForgeHax with MIT License 5 votes vote down vote up
public void keyTyped(char typedChar, int keyCode) throws IOException {
  if (isActive) {
    switch (keyCode) {
      case Keyboard.KEY_ESCAPE:
        isActive = false;
        break;
      
      case Keyboard.KEY_RETURN:
        isActive = false;
        // setValue(input);
        MC.player.sendMessage(new TextComponentString(input.toString()));
        break;
      
      case Keyboard.KEY_BACK:
        if (selectedIndex > -1) {
          input.deleteCharAt(selectedIndex);
          selectedIndex--;
        }
        break;
      
      case Keyboard.KEY_LEFT:
        selectedIndex--;
        break;
      
      case Keyboard.KEY_RIGHT:
        selectedIndex++;
        break;
      
      default:
        if (isValidChar(typedChar)) {
          selectedIndex++;
          input.insert(selectedIndex, typedChar);
        }
    }
    selectedIndex = MathHelper.clamp(selectedIndex, -1, input.length() - 1);
  }
}
 
Example 13
Source File: EditSliderScreen.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
	valueField.textboxKeyTyped(typedChar, keyCode);
	
	if(keyCode == Keyboard.KEY_RETURN)
		actionPerformed(doneButton);
	else if(keyCode == Keyboard.KEY_ESCAPE)
		mc.displayGuiScreen(prevScreen);
}
 
Example 14
Source File: TargetDelegate.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void keyPressed(KeyboardEvent event) {
	getCamera().keyPressed(event);
	switch (event.getKeyCode()) {
		case Keyboard.KEY_ESCAPE:
			pop();
			break;
		case Keyboard.KEY_SPACE:
		case Keyboard.KEY_RETURN:
			break;
		default:
			super.keyPressed(event);
			break;
	}
}
 
Example 15
Source File: Menu.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
protected void keyPressed(KeyboardEvent event) {
	switch(event.getKeyCode()) {
		case Keyboard.KEY_ESCAPE:
			break;
		default:
			super.keyPressed(event);
			break;
	}
}
 
Example 16
Source File: GuiLoadTofuTerrain.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
protected void keyTyped(char c, int code) {
    if (code == Keyboard.KEY_ESCAPE) {
        mc.displayGuiScreen(null);
        mc.setIngameFocus();
    }
}
 
Example 17
Source File: OptionsOverlay.java    From opsu-dance with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	e.consume();

	if (keyEntryRight) {
		if (Utils.isValidGameKey(e.keyCode)) {
			OPTION_KEY_RIGHT.setKeycode(e.keyCode);
		}
		keyEntryRight = false;
		return;
	}

	if (keyEntryLeft) {
		if (Utils.isValidGameKey(e.keyCode)) {
			OPTION_KEY_LEFT.setKeycode(e.keyCode);
		}
		keyEntryLeft = false;
		return;
	}

	if (e.keyCode == Keyboard.KEY_ESCAPE) {
		if (isAdjustingSlider) {
			cancelAdjustingSlider();
		}
		if (lastSearchText.length() != 0) {
			resetSearch();
			updateHoverOption(
				prevMouseX,
				prevMouseY,
				displayContainer.suppressHover
			);
			return;
		}
		this.exit();
		return;
	}

	if ((e.keyCode == Keyboard.KEY_RSHIFT || e.keyCode == Keyboard.KEY_LSHIFT) &&
		!Keyboard.isRepeatEvent() &&
		this.isAdjustingSlider)
	{
		this.sliderOptionPrecisionStartX = mouseX;
	}

	searchField.keyPressed(e);
	if (!searchField.getText().equals(lastSearchText)) {
		String newSearchText = searchField.getText().toLowerCase();
		if (!hasSearchResults(newSearchText)) {
			searchField.setText(lastSearchText);
			invalidSearchAnimationProgress = INVALID_SEARCH_ANIMATION_TIME;
			Random rand = new Random();
			invalidSearchImgRotation = 10 + rand.nextInt(10);
			invalidSearchTextRotation = 10 + rand.nextInt(10);
			if (rand.nextBoolean()) {
				invalidSearchImgRotation = -invalidSearchImgRotation;
			}
			if (rand.nextBoolean()) {
				invalidSearchTextRotation = -invalidSearchTextRotation;
			}
		} else {
			lastSearchText = newSearchText;
			updateSearch();
		}
	}
}
 
Example 18
Source File: GuiReactorRedstonePort.java    From BigReactors with MIT License 4 votes vote down vote up
@Override
protected void keyTyped(char inputChar, int keyCode) {
	boolean isAnyTextboxFocused = this.subInputRodSetting.isFocused() ||
									this.subInputRodSettingOff.isFocused() ||
									this.subOutputValue.isFocused();
	
       if (keyCode == Keyboard.KEY_ESCAPE ||
       		(!isAnyTextboxFocused && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())) {
           this.mc.thePlayer.closeScreen();
       }

       // Allow arrow keys, 0-9, and delete
       if(isKeyValidForValueInput(keyCode)) {
           if(this.subInputRodSetting.isFocused()) {
           	this.subInputRodSetting.textboxKeyTyped(inputChar,  keyCode);
               validateInputValues();
           }
           if(this.subInputRodSettingOff.isFocused()) {
           	this.subInputRodSettingOff.textboxKeyTyped(inputChar,  keyCode);
               validateInputValues();
           }
           if(this.subOutputValue.isFocused()) {
           	this.subOutputValue.textboxKeyTyped(inputChar,  keyCode);
           	validateOutputValues();
           }
           
       }
	
	if(keyCode == Keyboard.KEY_TAB) {
		/// ffffffuuuuuuuck tabbing
		if(this.subOutputValue.isFocused()) {
			this.subOutputValue.setFocused(false);
		}
		else if(this.subOutputValue.getVisible()) {
			this.subOutputValue.setFocused(true);
		}
		
		if(this.subInputRodSettingOff.getVisible()) {
			if(this.subInputRodSetting.isFocused()) {
				this.subInputRodSetting.setFocused(false);
				this.subInputRodSettingOff.setFocused(true);
			}
			else if(this.subInputRodSettingOff.isFocused()) {
				this.subInputRodSettingOff.setFocused(false);
			}
			else {
				this.subInputRodSetting.setFocused(true);
			}
		}
		else if(this.subInputRodSetting.getVisible()) {
			if(this.subInputRodSetting.isFocused()) {
				this.subInputRodSetting.setFocused(false);
			}
			else {
				this.subInputRodSetting.setFocused(true);
			}
		}
		// Else, nothing is visible, nothing is focused, screw you.
	}
	
	if(keyCode == Keyboard.KEY_RETURN && isAnyTextboxFocused) {
		this.subInputRodSetting.setFocused(false);
		this.subInputRodSettingOff.setFocused(false);
		this.subOutputValue.setFocused(false);
	}
}
 
Example 19
Source File: RegistrationForm.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
protected final void keyRepeat(KeyboardEvent event) {
	if (online)
		super.keyPressed(event);
	else if (event.getKeyCode() == Keyboard.KEY_ESCAPE)
		showQuitForm();
}
 
Example 20
Source File: Utils.java    From opsu-dance with GNU General Public License v3.0 4 votes vote down vote up
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);
}