diff --git a/CHANGELOG.md b/CHANGELOG.md
index d392208..3badedf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,7 +11,7 @@ Jump to version:
## 5.4.0 (Unreleased)
### MLEM
Additions
-- Added consuming variants of IsPressed methods to InputHandler
+- Added consuming variants of IsPressed methods to InputHandler and Keybind
- Added SpriteBatchContext struct and extensions
- Added InputHandler.InvertPressBehavior
diff --git a/MLEM/Input/Keybind.cs b/MLEM/Input/Keybind.cs
index 1ba8595..ddde6aa 100644
--- a/MLEM/Input/Keybind.cs
+++ b/MLEM/Input/Keybind.cs
@@ -131,6 +131,21 @@ namespace MLEM.Input {
return false;
}
+ ///
+ /// Returns whether this keybind is considered to be pressed.
+ /// See for more information.
+ ///
+ /// The input handler to query the keys with
+ /// The index of the gamepad to query, or -1 to query all gamepads
+ /// Whether this keybind is considered to be pressed
+ public bool TryConsumePressed(InputHandler handler, int gamepadIndex = -1) {
+ foreach (var combination in this.combinations) {
+ if (combination.TryConsumePressed(handler, gamepadIndex))
+ return true;
+ }
+ return false;
+ }
+
///
/// Returns whether any of this keybind's modifier keys are currently down.
/// See for more information.
@@ -242,6 +257,17 @@ namespace MLEM.Input {
return this.IsModifierDown(handler, gamepadIndex) && handler.IsPressed(this.Key, gamepadIndex);
}
+ ///
+ /// Returns whether this combination is currently pressed and the press has not been consumed yet.
+ /// A combination is considered consumed if this method has already returned true previously since the last call.
+ ///
+ /// The input handler to query the keys with
+ /// The index of the gamepad to query, or -1 to query all gamepads
+ /// Whether this combination is pressed
+ public bool TryConsumePressed(InputHandler handler, int gamepadIndex = -1) {
+ return this.IsModifierDown(handler, gamepadIndex) && handler.TryConsumePressed(this.Key, gamepadIndex);
+ }
+
///
/// Returns whether this combination's modifier keys are currently down
///