mirror of https://github.com/FabricMC/yarn.git
Document KeyBinding.isPressed and KeyBinding.wasPressed (#2393)
* Document KeyBinding.isPressed and KeyBinding.wasPressed * Apply suggestions from code review Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: liach <7806504+liach@users.noreply.github.com>
This commit is contained in:
parent
4e9beace48
commit
4f1bb0a391
|
@ -51,9 +51,33 @@ CLASS net/minecraft/class_304 net/minecraft/client/option/KeyBinding
|
|||
METHOD method_1433 matchesMouse (I)Z
|
||||
ARG 1 code
|
||||
METHOD method_1434 isPressed ()Z
|
||||
COMMENT {@return if the key is being held down}
|
||||
COMMENT
|
||||
COMMENT <p>Note that if you are continuously calling this method (like every
|
||||
COMMENT tick), it doesn't always catch all key presses. This is because the key
|
||||
COMMENT can be pressed and released before the next check.
|
||||
COMMENT
|
||||
COMMENT @see #wasPressed()
|
||||
METHOD method_1435 equals (Lnet/minecraft/class_304;)Z
|
||||
ARG 1 other
|
||||
METHOD method_1436 wasPressed ()Z
|
||||
COMMENT {@return if the key was pressed}
|
||||
COMMENT
|
||||
COMMENT <p>A key binding counts the number of times the key is pressed. This
|
||||
COMMENT method "consumes" it and returns {@code true} as many times as the key
|
||||
COMMENT is pressed.
|
||||
COMMENT
|
||||
COMMENT <p>To consume all remaining key presses, while-loop idiom can be used:
|
||||
COMMENT <pre>
|
||||
COMMENT {@code
|
||||
COMMENT while(keyBinding.wasPressed()) {
|
||||
COMMENT // do your action
|
||||
COMMENT }
|
||||
COMMENT }
|
||||
COMMENT </pre>
|
||||
COMMENT
|
||||
COMMENT @see #isPressed()
|
||||
COMMENT @see <a href="https://bugs.mojang.com/browse/MC-118107">MC-118107</a>
|
||||
METHOD method_1437 unpressAll ()V
|
||||
METHOD method_16007 getBoundKeyLocalizedText ()Lnet/minecraft/class_2561;
|
||||
METHOD method_23481 setPressed (Z)V
|
||||
|
|
Loading…
Reference in New Issue