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

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

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

Keyboard.getKeyName介绍

暂无

代码示例

代码示例来源:origin: org.slick2d/slick2d-core

/**
 * Get the character representation of the key identified by the specified code
 * 
 * @param code The key code of the key to retrieve the name of
 * @return The name or character representation of the key requested
 */
public static String getKeyName(int code) {
  return Keyboard.getKeyName(code);
}

代码示例来源:origin: CoFH/CoFHCore

public static String getKeyName(int key) {
  if (key < 0) {
    return I18n.translateToLocalFormatted("key.mouseButton", key + 101);
  } else if (key > Keyboard.KEYBOARD_SIZE) {
    return Keyboard.getKeyName(0);
  }
  return Keyboard.getKeyName(key);
}

代码示例来源:origin: lorddusk/HQM

public static String[] toConfig() {
  List<String> list = new ArrayList<>();
  for (Map.Entry<Integer, Set<EditMode>> entry : keyMap.entrySet())
    for (EditMode mode : entry.getValue())
      list.add(Keyboard.getKeyName(entry.getKey()) + ":" + mode.name().toLowerCase());
  return list.toArray(new String[list.size()]);
}

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

/**
 * @param keyBindingIndex the index in <code>ZyinHUDKeyHandlers.KEY_BINDINGS[]</code>
 * @return hotkey as a string
 */
private String GetKeyBindingAsString(int keyBindingIndex)
{
  try {
    return Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[keyBindingIndex].getKeyCode());
  }
  catch (ArrayIndexOutOfBoundsException e) {
    return "[?]";	//A user reported having getKeyCode() returning -89 and causing this exception
  }
}

代码示例来源:origin: sinkillerj/ProjectE

public static String getKeyName(KeyBinding k)
  {
    int keyCode = k.getKeyCode();
    if (keyCode > Keyboard.getKeyCount() || keyCode < 0)
    {
      return "INVALID KEY";
    }
    return Keyboard.getKeyName(keyCode);
  }
}

代码示例来源:origin: sinkillerj/ProjectE

/**
 * Get the key name this PEKeybind is bound to.
 */
public static String getKeyName(PEKeybind k)
{
  int keyCode = peToMc.get(k).getKeyCode();
  if (keyCode > Keyboard.getKeyCount() || keyCode < 0)
  {
    return "INVALID KEY";
  }
  return Keyboard.getKeyName(keyCode);
}

代码示例来源:origin: vadis365/TheErebus

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> list, ITooltipFlag flag) {
  if (canFly()) {
    list.add(new TextComponentTranslation("tooltip.erebus.poweredglider").getFormattedText());
    list.add(new TextComponentTranslation("tooltip.erebus.gliderpoweredkey").getFormattedText() + ": " + Keyboard.getKeyName(KeyBindingHandler.POWERED_GLIDE.getKeyCode()));
  }
  list.add(new TextComponentTranslation("tooltip.erebus.gliderglidekey").getFormattedText() + ": " + Keyboard.getKeyName(KeyBindingHandler.GLIDE.getKeyCode()));
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

public String getDetails(int level) {
  String key = "Unknown";
  try {
    key = Keyboard.getKeyName(ClientProxy.keyHandler.getBinding(KeyHandler.ABILITY_USE_KEY).getKeyCode());
  } catch (Exception ignored) {
  }
  return MOStringHelper.translateToLocal(getUnlocalizedDetails(), key);
}

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

/**
 * Searches Minecraft's key bindings to get the hotkey based on the hotkey description, then caches the result for future use.
 * @return String representation of the hotkey, e.x. "K", "LMENU"
 */
public String GetHotkey()
{
  if(hotkey == null)
  {
    //get key binding in Minecraft
    KeyBinding keyBinding = FindKeyBinding(GetHotkeyDescription());
    if(keyBinding != null)
    {
      SetHotkey(hotkey);
      return Keyboard.getKeyName(keyBinding.getKeyCode());
    }
    else
    {
      return "?";
    }
  }
  else
    return hotkey;
}

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

/**
 * Called when a key is pressed on the GuiZyinHUDOptions screen.
 * Updates Minecraft's keybinding.
 * @param newHotkey e.x. 37 (K), 1 (Esc), 55 (*)
 */
public void ApplyHotkey(int newHotkey)
{
  waitingForHotkeyInput = false;
  hotkey = Keyboard.getKeyName(newHotkey);
  
  //SetHotkey(hotkey);
  UpdateDisplayString();
  
  //update key binding in Minecraft
  KeyBinding keyBinding = FindKeyBinding(GetHotkeyDescription());
  if(keyBinding != null)
  {
    keyBinding.setKeyCode(newHotkey);
    KeyBinding.resetKeyBindingArrayAndHash();
  }
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
  if(!playerIn.isSneaking())
  {
    if(SeatUtil.sitOnBlockWithRotationOffset(worldIn, pos.getX(), pos.getY(), pos.getZ(), playerIn, 0.4D, getMetaFromState(state), 0.1D))
    {
      if(worldIn.isRemote)
      {
        String key = new TextComponentTranslation("cfm.message.toilet", Keyboard.getKeyName(InputHandler.KEY_FART.getKeyCode())).getUnformattedComponentText();
        playerIn.sendMessage(new TextComponentString(TextFormatting.YELLOW + key));
      }
      worldIn.updateComparatorOutputLevel(pos, this);
    }
  }
  else
  {
    List<EntityItem> items = worldIn.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1.0D, pos.getY() + 1.0D, pos.getZ() + 1.0D).grow(1D));
    for(EntityItem item : items)
    {
      item.setDead();
    }
    worldIn.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, FurnitureSounds.flush, SoundCategory.BLOCKS, 0.75F, 1.0F, false);
  }
  return true;
}

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

p.comment = "The format used when sending your coordiantes in a chat message by pressing '" + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[1].getKeyCode()) + "'. {x}{y}{z} are replaced with actual coordiantes.";
if(loadSettings)
  Coordinates.ChatStringFormat = p.getString();
      + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[8].getKeyCode())+" and + + "
      + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[8].getKeyCode())+".";
if(loadSettings)
  SafeOverlay.instance.SetDrawDistance(p.getInt(20));
p.comment = "Enable/Disable showing unsafe areas through walls. Toggle in game with Ctrl + "+Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[8].getKeyCode())+".";
if(loadSettings)
  SafeOverlay.instance.SetSeeUnsafePositionsThroughWalls(p.getBoolean(false));
p.comment = "Enables pressing " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[3].getKeyCode())
      + " to eat food even if it is  in your inventory and not your hotbar.";
if(loadSettings)
p.comment = "Enables pressing " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[9].getKeyCode())
      + " to swap between your sword and bow.";
if(loadSettings)
p.comment = "Enables pressing " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[4].getKeyCode())
      + " to use an enderpearl even if it is  in your inventory and not your hotbar.";
if(loadSettings)
p.comment = "Enables pressing " + Keyboard.getKeyName(ZyinHUDKeyHandlers.KEY_BINDINGS[6].getKeyCode())
      + " to drink a potion even if it is  in your inventory and not your hotbar.";
if(loadSettings)

相关文章