FabricKeyBinding KeyCode exposure
jamesxsc opened this issue ยท 3 comments
Having needed to access the KeyCode of a KeyBinding with difficulty, I think FabricKeyBinding should expose the KeyCode with a method such as below.
public class FabricKeyBinding extends KeyBinding {
...
public InputUtil.KeyCode getKeyCode() {
return InputUtil.fromName(this.getName()); // KeyBinding#getName() from superclass to
//obtain name of KeyCode.
}
...
}
Please let me know what you think of the feature, the above suggested implementation, and anything else such as a different implementation.
Fabric API is meant to be minimal, to make maintenance and updating across Minecraft versions faster and easier. So potential features need to be useful to a wide range of people. From the limited information you've given, it looks like your usecase is niche, so I think this feature does not belong in Fabric API.
I suggest using a mixin, specifically an Accessor mixin.
Bumping this issue to say that I agree the configured KeyCode needs some sort of getter method. For some reason, it only allows access to the default key, which is silly. We already have the FabricKeyBinding class, so it would be fairly easy to just add a getter method.
This has been implemented in 7dfef87