Class KeyBinding

java.lang.Object
net.minecraft.client.option.KeyBinding
All Implemented Interfaces:
Comparable<KeyBinding>
Direct Known Subclasses:
StickyKeyBinding

@Environment(CLIENT) public class KeyBinding extends Object implements Comparable<KeyBinding>
Mappings:
Namespace Name
named net/minecraft/client/option/KeyBinding
intermediary net/minecraft/class_304
official fmd
  • Field Details

    • KEYS_BY_ID

      private static final Map<String,KeyBinding> KEYS_BY_ID
      Mappings:
      Namespace Name Mixin selector
      named KEYS_BY_ID Lnet/minecraft/client/option/KeyBinding;KEYS_BY_ID:Ljava/util/Map;
      intermediary field_1657 Lnet/minecraft/class_304;field_1657:Ljava/util/Map;
      official h Lfmd;h:Ljava/util/Map;
    • KEY_TO_BINDINGS

      private static final Map<InputUtil.Key,KeyBinding> KEY_TO_BINDINGS
      Mappings:
      Namespace Name Mixin selector
      named KEY_TO_BINDINGS Lnet/minecraft/client/option/KeyBinding;KEY_TO_BINDINGS:Ljava/util/Map;
      intermediary field_1658 Lnet/minecraft/class_304;field_1658:Ljava/util/Map;
      official i Lfmd;i:Ljava/util/Map;
    • KEY_CATEGORIES

      private static final Set<String> KEY_CATEGORIES
      Mappings:
      Namespace Name Mixin selector
      named KEY_CATEGORIES Lnet/minecraft/client/option/KeyBinding;KEY_CATEGORIES:Ljava/util/Set;
      intermediary field_1652 Lnet/minecraft/class_304;field_1652:Ljava/util/Set;
      official j Lfmd;j:Ljava/util/Set;
    • MOVEMENT_CATEGORY

      public static final String MOVEMENT_CATEGORY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named MOVEMENT_CATEGORY Lnet/minecraft/client/option/KeyBinding;MOVEMENT_CATEGORY:Ljava/lang/String;
      intermediary field_32136 Lnet/minecraft/class_304;field_32136:Ljava/lang/String;
      official a Lfmd;a:Ljava/lang/String;
    • MISC_CATEGORY

      public static final String MISC_CATEGORY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named MISC_CATEGORY Lnet/minecraft/client/option/KeyBinding;MISC_CATEGORY:Ljava/lang/String;
      intermediary field_32137 Lnet/minecraft/class_304;field_32137:Ljava/lang/String;
      official b Lfmd;b:Ljava/lang/String;
    • MULTIPLAYER_CATEGORY

      public static final String MULTIPLAYER_CATEGORY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named MULTIPLAYER_CATEGORY Lnet/minecraft/client/option/KeyBinding;MULTIPLAYER_CATEGORY:Ljava/lang/String;
      intermediary field_32138 Lnet/minecraft/class_304;field_32138:Ljava/lang/String;
      official c Lfmd;c:Ljava/lang/String;
    • GAMEPLAY_CATEGORY

      public static final String GAMEPLAY_CATEGORY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named GAMEPLAY_CATEGORY Lnet/minecraft/client/option/KeyBinding;GAMEPLAY_CATEGORY:Ljava/lang/String;
      intermediary field_32139 Lnet/minecraft/class_304;field_32139:Ljava/lang/String;
      official d Lfmd;d:Ljava/lang/String;
    • INVENTORY_CATEGORY

      public static final String INVENTORY_CATEGORY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named INVENTORY_CATEGORY Lnet/minecraft/client/option/KeyBinding;INVENTORY_CATEGORY:Ljava/lang/String;
      intermediary field_32140 Lnet/minecraft/class_304;field_32140:Ljava/lang/String;
      official e Lfmd;e:Ljava/lang/String;
    • UI_CATEGORY

      public static final String UI_CATEGORY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named UI_CATEGORY Lnet/minecraft/client/option/KeyBinding;UI_CATEGORY:Ljava/lang/String;
      intermediary field_32141 Lnet/minecraft/class_304;field_32141:Ljava/lang/String;
      official f Lfmd;f:Ljava/lang/String;
    • CREATIVE_CATEGORY

      public static final String CREATIVE_CATEGORY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named CREATIVE_CATEGORY Lnet/minecraft/client/option/KeyBinding;CREATIVE_CATEGORY:Ljava/lang/String;
      intermediary field_32142 Lnet/minecraft/class_304;field_32142:Ljava/lang/String;
      official g Lfmd;g:Ljava/lang/String;
    • CATEGORY_ORDER_MAP

      private static final Map<String,Integer> CATEGORY_ORDER_MAP
      Mappings:
      Namespace Name Mixin selector
      named CATEGORY_ORDER_MAP Lnet/minecraft/client/option/KeyBinding;CATEGORY_ORDER_MAP:Ljava/util/Map;
      intermediary field_1656 Lnet/minecraft/class_304;field_1656:Ljava/util/Map;
      official k Lfmd;k:Ljava/util/Map;
    • translationKey

      private final String translationKey
      Mappings:
      Namespace Name Mixin selector
      named translationKey Lnet/minecraft/client/option/KeyBinding;translationKey:Ljava/lang/String;
      intermediary field_1660 Lnet/minecraft/class_304;field_1660:Ljava/lang/String;
      official l Lfmd;l:Ljava/lang/String;
    • defaultKey

      private final InputUtil.Key defaultKey
      Mappings:
      Namespace Name Mixin selector
      named defaultKey Lnet/minecraft/client/option/KeyBinding;defaultKey:Lnet/minecraft/client/util/InputUtil$Key;
      intermediary field_1654 Lnet/minecraft/class_304;field_1654:Lnet/minecraft/class_3675$class_306;
      official m Lfmd;m:Lffm$a;
    • category

      private final String category
      Mappings:
      Namespace Name Mixin selector
      named category Lnet/minecraft/client/option/KeyBinding;category:Ljava/lang/String;
      intermediary field_1659 Lnet/minecraft/class_304;field_1659:Ljava/lang/String;
      official n Lfmd;n:Ljava/lang/String;
    • boundKey

      private InputUtil.Key boundKey
      Mappings:
      Namespace Name Mixin selector
      named boundKey Lnet/minecraft/client/option/KeyBinding;boundKey:Lnet/minecraft/client/util/InputUtil$Key;
      intermediary field_1655 Lnet/minecraft/class_304;field_1655:Lnet/minecraft/class_3675$class_306;
      official o Lfmd;o:Lffm$a;
    • pressed

      private boolean pressed
      Mappings:
      Namespace Name Mixin selector
      named pressed Lnet/minecraft/client/option/KeyBinding;pressed:Z
      intermediary field_1653 Lnet/minecraft/class_304;field_1653:Z
      official p Lfmd;p:Z
    • timesPressed

      private int timesPressed
      Mappings:
      Namespace Name Mixin selector
      named timesPressed Lnet/minecraft/client/option/KeyBinding;timesPressed:I
      intermediary field_1661 Lnet/minecraft/class_304;field_1661:I
      official q Lfmd;q:I
  • Constructor Details

    • KeyBinding

      public KeyBinding(String translationKey, int code, String category)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/client/option/KeyBinding;<init>(Ljava/lang/String;ILjava/lang/String;)V
      intermediary <init> Lnet/minecraft/class_304;<init>(Ljava/lang/String;ILjava/lang/String;)V
      official <init> Lfmd;<init>(Ljava/lang/String;ILjava/lang/String;)V
    • KeyBinding

      public KeyBinding(String translationKey, InputUtil.Type type, int code, String category)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/client/option/KeyBinding;<init>(Ljava/lang/String;Lnet/minecraft/client/util/InputUtil$Type;ILjava/lang/String;)V
      intermediary <init> Lnet/minecraft/class_304;<init>(Ljava/lang/String;Lnet/minecraft/class_3675$class_307;ILjava/lang/String;)V
      official <init> Lfmd;<init>(Ljava/lang/String;Lffm$b;ILjava/lang/String;)V
  • Method Details

    • onKeyPressed

      public static void onKeyPressed(InputUtil.Key key)
      Mappings:
      Namespace Name Mixin selector
      named onKeyPressed Lnet/minecraft/client/option/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;)V
      intermediary method_1420 Lnet/minecraft/class_304;method_1420(Lnet/minecraft/class_3675$class_306;)V
      official a Lfmd;a(Lffm$a;)V
    • setKeyPressed

      public static void setKeyPressed(InputUtil.Key key, boolean pressed)
      Mappings:
      Namespace Name Mixin selector
      named setKeyPressed Lnet/minecraft/client/option/KeyBinding;setKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;Z)V
      intermediary method_1416 Lnet/minecraft/class_304;method_1416(Lnet/minecraft/class_3675$class_306;Z)V
      official a Lfmd;a(Lffm$a;Z)V
    • updatePressedStates

      public static void updatePressedStates()
      Mappings:
      Namespace Name Mixin selector
      named updatePressedStates Lnet/minecraft/client/option/KeyBinding;updatePressedStates()V
      intermediary method_1424 Lnet/minecraft/class_304;method_1424()V
      official a Lfmd;a()V
    • unpressAll

      public static void unpressAll()
      Mappings:
      Namespace Name Mixin selector
      named unpressAll Lnet/minecraft/client/option/KeyBinding;unpressAll()V
      intermediary method_1437 Lnet/minecraft/class_304;method_1437()V
      official b Lfmd;b()V
    • untoggleStickyKeys

      public static void untoggleStickyKeys()
      Mappings:
      Namespace Name Mixin selector
      named untoggleStickyKeys Lnet/minecraft/client/option/KeyBinding;untoggleStickyKeys()V
      intermediary method_52231 Lnet/minecraft/class_304;method_52231()V
      official c Lfmd;c()V
    • updateKeysByCode

      public static void updateKeysByCode()
      Mappings:
      Namespace Name Mixin selector
      named updateKeysByCode Lnet/minecraft/client/option/KeyBinding;updateKeysByCode()V
      intermediary method_1426 Lnet/minecraft/class_304;method_1426()V
      official d Lfmd;d()V
    • isPressed

      public boolean isPressed()
      Returns if the key is being held down.

      Note that if you are continuously calling this method (like every tick), it doesn't always catch all key presses. This is because the key can be pressed and released before the next check.

      Returns:
      if the key is being held down
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named isPressed Lnet/minecraft/client/option/KeyBinding;isPressed()Z
      intermediary method_1434 Lnet/minecraft/class_304;method_1434()Z
      official e Lfmd;e()Z
    • getCategory

      public String getCategory()
      Mappings:
      Namespace Name Mixin selector
      named getCategory Lnet/minecraft/client/option/KeyBinding;getCategory()Ljava/lang/String;
      intermediary method_1423 Lnet/minecraft/class_304;method_1423()Ljava/lang/String;
      official f Lfmd;f()Ljava/lang/String;
    • wasPressed

      public boolean wasPressed()
      Returns if the key was pressed.

      A key binding counts the number of times the key is pressed. This method "consumes" it and returns true as many times as the key is pressed.

      To consume all remaining key presses, while-loop idiom can be used:

       
       while(keyBinding.wasPressed()) {
         // do your action
       }
       
       
      Returns:
      if the key was pressed
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named wasPressed Lnet/minecraft/client/option/KeyBinding;wasPressed()Z
      intermediary method_1436 Lnet/minecraft/class_304;method_1436()Z
      official g Lfmd;g()Z
    • reset

      private void reset()
      Mappings:
      Namespace Name Mixin selector
      named reset Lnet/minecraft/client/option/KeyBinding;reset()V
      intermediary method_1425 Lnet/minecraft/class_304;method_1425()V
      official n Lfmd;n()V
    • getTranslationKey

      public String getTranslationKey()
      Mappings:
      Namespace Name Mixin selector
      named getTranslationKey Lnet/minecraft/client/option/KeyBinding;getTranslationKey()Ljava/lang/String;
      intermediary method_1431 Lnet/minecraft/class_304;method_1431()Ljava/lang/String;
      official h Lfmd;h()Ljava/lang/String;
    • getDefaultKey

      public InputUtil.Key getDefaultKey()
      Mappings:
      Namespace Name Mixin selector
      named getDefaultKey Lnet/minecraft/client/option/KeyBinding;getDefaultKey()Lnet/minecraft/client/util/InputUtil$Key;
      intermediary method_1429 Lnet/minecraft/class_304;method_1429()Lnet/minecraft/class_3675$class_306;
      official i Lfmd;i()Lffm$a;
    • setBoundKey

      public void setBoundKey(InputUtil.Key boundKey)
      Mappings:
      Namespace Name Mixin selector
      named setBoundKey Lnet/minecraft/client/option/KeyBinding;setBoundKey(Lnet/minecraft/client/util/InputUtil$Key;)V
      intermediary method_1422 Lnet/minecraft/class_304;method_1422(Lnet/minecraft/class_3675$class_306;)V
      official b Lfmd;b(Lffm$a;)V
    • compareTo

      public int compareTo(KeyBinding keyBinding)
      Specified by:
      compareTo in interface Comparable<KeyBinding>
      Mappings:
      Namespace Name Mixin selector
      named compareTo Lnet/minecraft/client/option/KeyBinding;compareTo(Lnet/minecraft/client/option/KeyBinding;)I
      intermediary method_1430 Lnet/minecraft/class_304;method_1430(Lnet/minecraft/class_304;)I
      official a Lfmd;a(Lfmd;)I
    • getLocalizedName

      public static Supplier<Text> getLocalizedName(String id)
      Mappings:
      Namespace Name Mixin selector
      named getLocalizedName Lnet/minecraft/client/option/KeyBinding;getLocalizedName(Ljava/lang/String;)Ljava/util/function/Supplier;
      intermediary method_1419 Lnet/minecraft/class_304;method_1419(Ljava/lang/String;)Ljava/util/function/Supplier;
      official a Lfmd;a(Ljava/lang/String;)Ljava/util/function/Supplier;
    • equals

      public boolean equals(KeyBinding other)
      Mappings:
      Namespace Name Mixin selector
      named equals Lnet/minecraft/client/option/KeyBinding;equals(Lnet/minecraft/client/option/KeyBinding;)Z
      intermediary method_1435 Lnet/minecraft/class_304;method_1435(Lnet/minecraft/class_304;)Z
      official b Lfmd;b(Lfmd;)Z
    • isUnbound

      public boolean isUnbound()
      Mappings:
      Namespace Name Mixin selector
      named isUnbound Lnet/minecraft/client/option/KeyBinding;isUnbound()Z
      intermediary method_1415 Lnet/minecraft/class_304;method_1415()Z
      official j Lfmd;j()Z
    • matchesKey

      public boolean matchesKey(int keyCode, int scanCode)
      Mappings:
      Namespace Name Mixin selector
      named matchesKey Lnet/minecraft/client/option/KeyBinding;matchesKey(II)Z
      intermediary method_1417 Lnet/minecraft/class_304;method_1417(II)Z
      official a Lfmd;a(II)Z
    • matchesMouse

      public boolean matchesMouse(int code)
      Mappings:
      Namespace Name Mixin selector
      named matchesMouse Lnet/minecraft/client/option/KeyBinding;matchesMouse(I)Z
      intermediary method_1433 Lnet/minecraft/class_304;method_1433(I)Z
      official a Lfmd;a(I)Z
    • getBoundKeyLocalizedText

      public Text getBoundKeyLocalizedText()
      Mappings:
      Namespace Name Mixin selector
      named getBoundKeyLocalizedText Lnet/minecraft/client/option/KeyBinding;getBoundKeyLocalizedText()Lnet/minecraft/text/Text;
      intermediary method_16007 Lnet/minecraft/class_304;method_16007()Lnet/minecraft/class_2561;
      official k Lfmd;k()Lxv;
    • isDefault

      public boolean isDefault()
      Mappings:
      Namespace Name Mixin selector
      named isDefault Lnet/minecraft/client/option/KeyBinding;isDefault()Z
      intermediary method_1427 Lnet/minecraft/class_304;method_1427()Z
      official l Lfmd;l()Z
    • getBoundKeyTranslationKey

      public String getBoundKeyTranslationKey()
      Mappings:
      Namespace Name Mixin selector
      named getBoundKeyTranslationKey Lnet/minecraft/client/option/KeyBinding;getBoundKeyTranslationKey()Ljava/lang/String;
      intermediary method_1428 Lnet/minecraft/class_304;method_1428()Ljava/lang/String;
      official m Lfmd;m()Ljava/lang/String;
    • setPressed

      public void setPressed(boolean pressed)
      Mappings:
      Namespace Name Mixin selector
      named setPressed Lnet/minecraft/client/option/KeyBinding;setPressed(Z)V
      intermediary method_23481 Lnet/minecraft/class_304;method_23481(Z)V
      official a Lfmd;a(Z)V