Class KeyBindingHelper

java.lang.Object
net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper

public final class KeyBindingHelper extends Object
Helper for registering KeyMappings.

 KeyBinding left = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.example.left", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_P, KeyBinding.Category.MISC));
 KeyBinding right = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.example.right", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_U, KeyBinding.Category.MISC));
 
See Also:
  • KeyMapping
  • ToggleKeyMapping
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.mojang.blaze3d.platform.InputConstants.Key
    getBoundKeyOf(net.minecraft.client.KeyMapping keyBinding)
    Returns the configured KeyCode bound to the KeyBinding from the player's settings.
    static net.minecraft.client.KeyMapping
    registerKeyBinding(net.minecraft.client.KeyMapping keyBinding)
    Registers the keybinding and add the keybinding category if required.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • registerKeyBinding

      public static net.minecraft.client.KeyMapping registerKeyBinding(net.minecraft.client.KeyMapping keyBinding)
      Registers the keybinding and add the keybinding category if required.
      Parameters:
      keyBinding - the keybinding
      Returns:
      the keybinding itself
      Throws:
      IllegalArgumentException - when a key binding with the same ID is already registered
    • getBoundKeyOf

      public static com.mojang.blaze3d.platform.InputConstants.Key getBoundKeyOf(net.minecraft.client.KeyMapping keyBinding)
      Returns the configured KeyCode bound to the KeyBinding from the player's settings.
      Parameters:
      keyBinding - the keybinding
      Returns:
      configured KeyCode