org.lwjgl.input.Keyboard.getEventKey()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(224)

本文整理了Java中org.lwjgl.input.Keyboard.getEventKey()方法的一些代码示例,展示了Keyboard.getEventKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keyboard.getEventKey()方法的具体详情如下:
包路径:org.lwjgl.input.Keyboard
类名称:Keyboard
方法名:getEventKey

Keyboard.getEventKey介绍

暂无

代码示例

代码示例来源:origin: MovingBlocks/Terasology

@Override
  public Queue<KeyboardAction> getInputQueue() {
    Queue<KeyboardAction> result = Queues.newArrayDeque();

    while (Keyboard.next()) {
      ButtonState state;
      if (Keyboard.isRepeatEvent()) {
        state = ButtonState.REPEAT;
      } else {
        state = (Keyboard.getEventKeyState()) ? ButtonState.DOWN : ButtonState.UP;
      }
      Input input = InputType.KEY.getInput(Keyboard.getEventKey());
      result.add(new KeyboardAction(input, state, Keyboard.getEventCharacter()));
    }

    return result;
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

private static void trackReleasedKeys() {
  int key = Keyboard.getEventKey();
  if (releaseableKeys.contains(key)) {
    trackedKeyReleased = true;
  }
}

代码示例来源:origin: libgdx/libgdx

int keyCode = getGdxKeyCode(Keyboard.getEventKey());
char keyChar = Keyboard.getEventCharacter();
if (Keyboard.getEventKeyState() || (keyCode == 0 && keyChar != 0 && Character.isDefined(keyChar))) {

代码示例来源:origin: Zyin055/zyinhud

@SubscribeEvent
public void ClientTickEvent(ClientTickEvent event)
{
  //This tick handler is to overcome the GuiScreen + KeyInputEvent limitation
  //for Coordinates and QuickDeposit
  
  if (Keyboard.getEventKey() == KEY_BINDINGS[1].getKeyCode())
    CoordinatesKeyHandler.ClientTickEvent(event);
  else if(Keyboard.getEventKey() == KEY_BINDINGS[7].getKeyCode())
    QuickDepositKeyHandler.ClientTickEvent(event);
  
  //since this method is in the ClientTickEvent, it'll overcome the GuiScreen limitation of not handling mouse clicks
  FireUseBlockEvents();
}

代码示例来源:origin: libgdx/libgdx

int keyCode = getGdxKeyCode(Keyboard.getEventKey());
char keyChar = Keyboard.getEventCharacter();
if (Keyboard.getEventKeyState() || (keyCode == 0 && keyChar != 0 && Character.isDefined(keyChar))) {

代码示例来源:origin: CFPAOrg/I18nUpdateMod

/**
 * 单独功能,快速重载语言文件
 *
 * @return 是否成功
 */
private boolean reloadKeyHandler() {
  if (keyCodeCheck(reportKey.getKeyCode()) && Keyboard.isKeyDown(mainKey.getKeyCode()) && Keyboard.getEventKey() == reloadKey.getKeyCode()) {
    Minecraft.getMinecraft().getLanguageManager().onResourceManagerReload(Minecraft.getMinecraft().getResourceManager());
    Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_reload.success"));
    return true;
  }
  return false;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void update() {
  if (!context.isRenderable())
    return;
  
  Keyboard.poll();
  while (Keyboard.next()){
    int keyCode = Keyboard.getEventKey();
    char keyChar = Keyboard.getEventCharacter();
    boolean pressed = Keyboard.getEventKeyState();
    boolean down = Keyboard.isRepeatEvent();
    long time = Keyboard.getEventNanoseconds();
    KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down);
    evt.setTime(time);
    listener.onKeyEvent(evt);
  }
}

代码示例来源:origin: Vazkii/Botania

@SubscribeEvent
public static void buttonPressed(KeyboardInputEvent.Post event) {
  Minecraft mc = Minecraft.getMinecraft();
  if(mc.world == null || !supportedGuiFilter.test(mc.currentScreen)
      || Keyboard.getEventKey() != ClientProxy.CORPOREA_REQUEST.getKeyCode()
      || !Keyboard.getEventKeyState()
      || Keyboard.isRepeatEvent()
      || TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.player).isEmpty())
    return;
  ItemStack stack = getStackUnderMouse();
  if(stack != null && !stack.isEmpty()) {
    int count = 1;
    int max = stack.getMaxStackSize();
    if(GuiScreen.isShiftKeyDown()) {
      count = max;
      if(GuiScreen.isCtrlKeyDown())
        count /= 4;
    } else if(GuiScreen.isCtrlKeyDown())
      count = max / 2;
    if(count > 0) {
      String name = CorporeaHelper.stripControlCodes(stack.getDisplayName());
      String full = count + " " + name;
      mc.ingameGUI.getChatGUI().addToSentMessages(full);
      mc.player.sendChatMessage(full);
      event.setCanceled(true);
    }
  }
}

代码示例来源:origin: mezz/JustEnoughItems

private boolean handleKeyEvent() {
  char typedChar = Keyboard.getEventCharacter();
  int eventKey = Keyboard.getEventKey();
  return ((eventKey == 0 && typedChar >= 32) || Keyboard.getEventKeyState()) &&
    handleKeyDown(typedChar, eventKey);
}

代码示例来源:origin: Zyin055/zyinhud

public static void ClientTickEvent(ClientTickEvent event)
{
  if(mc.currentScreen != null && mc.currentScreen instanceof GuiChat)
  {
    if(Keyboard.getEventKey() == ZyinHUDKeyHandlers.KEY_BINDINGS[1].getKeyCode())
    {
      if(Keyboard.getEventKeyState())
      {
        if(keyDown == false)
          OnKeyDown();
        keyDown = true;
      }
      else
      {
        //if(keyDown == true)
          //OnKeyUp();
        keyDown = false;
      }
    }
    
  }
}

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

@SubscribeEvent
public void keyDown(InputEvent.KeyInputEvent event) {
  if (Keyboard.getEventKeyState() && !Keyboard.isRepeatEvent()) {
    doKey(Keyboard.getEventKey());
  }
}

代码示例来源:origin: nifty-gui/nifty-gui

private void processKeyboardEvents(@Nonnull final NiftyInputConsumer inputEventConsumer) {
 while (Keyboard.next()) {
  KeyboardInputEvent event = keyboardEventCreator.createEvent(Keyboard.getEventKey(),
    Keyboard.getEventCharacter(), Keyboard.getEventKeyState());
  // due to or short-circuiting on true, the event will get forward to keyboardEventsOut if keyboardEventsOut=true
  if (!niftyHasKeyboardFocus || !inputEventConsumer.processKeyboardEvent(event)) {
   keyboardEventsOut.offer(event);
  }
 }
}

代码示例来源:origin: AntiqueAtlasTeam/AntiqueAtlas

/** Handle keyboard input for this GUI and its children. */
@Override
public void handleKeyboardInput() throws IOException {
  boolean handled = false;
  // Traverse children backwards, because the topmost child should be the
  // first to process input:
  ListIterator<GuiComponent> iter = children.listIterator(children.size());
  while(iter.hasPrevious()) {
    GuiComponent child = iter.previous();
    child.handleKeyboardInput();
    if (child.hasHandledKeyboard) {
      child.hasHandledKeyboard = false;
      handled = true;
    }
  }
  if (!handled) {
    if (Keyboard.getEventKeyState()) {
      this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
    }
  }
}

代码示例来源:origin: ForestryMC/Binnie

public boolean isHelpMode() {
  if (Keyboard.getEventKeyState()) {
    if (KeyBindings.holdForHelpTooltips.isActiveAndMatches(Keyboard.getEventKey())) {
      return true;
    }
  }
  return Mouse.getEventButtonState() && KeyBindings.holdForHelpTooltips.isActiveAndMatches(Mouse.getEventButton() - 100);
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public void handleKeyboardInput() throws IOException {
  int key = Keyboard.getEventKey();
  boolean state = Keyboard.getEventKeyState();
  char ch = Keyboard.getEventCharacter();
  ActivationEvent evt = new ActivationEvent(state ? Listener.KEY_DOWN : Listener.KEY_UP, key, ch, state);
  for (GuiElement element : this.elements) {
    element.handleKeyboardInput(evt);
  }
  if (selectedWidget == null) {
    super.handleKeyboardInput();
  }
}

代码示例来源:origin: com.ardor3d/ardor3d-lwjgl

@Override
  protected KeyEvent computeNext() {
    if (!Keyboard.next()) {
      return endOfData();
    }
    final int keyCode = Keyboard.getEventKey();
    final boolean pressed = Keyboard.getEventKeyState();
    final char keyChar = Keyboard.getEventCharacter();
    final Key k = LwjglKey.findByCode(keyCode);
    return new KeyEvent(k, pressed ? KeyState.DOWN : KeyState.UP, keyChar);
  }
}

代码示例来源:origin: mezz/JustEnoughItems

@Override
  protected boolean onMouseClicked(int mouseX, int mouseY) {
    if (Config.isOverlayEnabled()) {
      if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LCONTROL || Keyboard.getEventKey() == Keyboard.KEY_RCONTROL)) {
        Config.toggleCheatItemsEnabled();
      } else {
        Minecraft minecraft = Minecraft.getMinecraft();
        if (minecraft.currentScreen != null) {
          GuiScreen configScreen = new JEIModConfigGui(minecraft.currentScreen);
          parent.updateScreen(configScreen, false);
          minecraft.displayGuiScreen(configScreen);
        }
      }
      return true;
    }
    return false;
  }
}

代码示例来源:origin: Vazkii/Quark

@SubscribeEvent
public void onKeypress(GuiScreenEvent.KeyboardInputEvent.Pre event) {
  if(searchBar != null && searchBar.isFocused() && Keyboard.getEventKeyState()) {
    char eventChar = Keyboard.getEventCharacter();
    int eventCode = Keyboard.getEventKey();
    
    searchBar.textboxKeyTyped(eventChar, eventCode);
    text = searchBar.getText();
    
    event.setCanceled(eventCode != 1);
  }
}

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

protected synchronized boolean getNextDeviceEvent(Event event) throws IOException {
  if (!org.lwjgl.input.Keyboard.isCreated())
    return false;
  if (!org.lwjgl.input.Keyboard.next())
    return false;
  int lwjgl_key = org.lwjgl.input.Keyboard.getEventKey();
  if (lwjgl_key == org.lwjgl.input.Keyboard.KEY_NONE)
    return false;
  Component.Identifier.Key key_id = KeyMap.map(lwjgl_key);
  if (key_id == null)
    return false;
  Component key = getComponent(key_id);
  if (key == null)
    return false;
  float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0;
  event.set(key, value, org.lwjgl.input.Keyboard.getEventNanoseconds());
  return true;
}

代码示例来源:origin: us.ihmc.thirdparty.jme/jme3-lwjgl

public void update() {
  if (!context.isRenderable())
    return;
  
  Keyboard.poll();
  while (Keyboard.next()){
    int keyCode = Keyboard.getEventKey();
    char keyChar = Keyboard.getEventCharacter();
    boolean pressed = Keyboard.getEventKeyState();
    boolean down = Keyboard.isRepeatEvent();
    long time = Keyboard.getEventNanoseconds();
    KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down);
    evt.setTime(time);
    listener.onKeyEvent(evt);
  }
}

相关文章