pub struct KeyRepeatGate<K: Eq + Hash + Copy> { /* private fields */ }Expand description
The debouncer. Generic over the key type so consumers can use
Action, &'static str, or any other Eq+Hash+Copy token.
Default::default() gives a gate with the 80ms DEFAULT_MIN_INTERVAL.
Implementations§
Source§impl<K: Eq + Hash + Copy> KeyRepeatGate<K>
impl<K: Eq + Hash + Copy> KeyRepeatGate<K>
Sourcepub fn with_interval(min_interval: Duration) -> Self
pub fn with_interval(min_interval: Duration) -> Self
Construct with a custom min-interval. Shorter = less
debouncing; longer = more aggressive throttling;
Duration::ZERO = pass-through.
Sourcepub fn try_pass(&mut self, key: K) -> bool
pub fn try_pass(&mut self, key: K) -> bool
Attempt to pass an event for key. Returns true if at
least min_interval has elapsed since the last accepted
pass (or there was no prior pass). On true, the
timestamp is updated.
Returns false (and leaves the timestamp untouched) when
the call lands within the window — the caller should drop
the event.
Sourcepub fn try_pass_at(&mut self, key: K, now: Instant) -> bool
pub fn try_pass_at(&mut self, key: K, now: Instant) -> bool
Same as try_pass but with an explicit timestamp — for
tests that don’t depend on wall-clock timing.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset all timestamps. Use when window focus changes or the operator explicitly clears keybind state.
Sourcepub fn clear_key(&mut self, key: K)
pub fn clear_key(&mut self, key: K)
Forget timestamps just for key. Useful when one action’s
debounce state should reset without affecting others.
Sourcepub fn min_interval(&self) -> Duration
pub fn min_interval(&self) -> Duration
Read the configured min-interval (diagnostic / introspection).
Sourcepub fn set_min_interval(&mut self, interval: Duration)
pub fn set_min_interval(&mut self, interval: Duration)
Update the min-interval at runtime. Existing timestamps are preserved — the new interval applies to subsequent checks.