13 lines
390 B
Swift
13 lines
390 B
Swift
public struct ModifierKeyTracker {
|
|
private var isDown = false
|
|
|
|
public init() {}
|
|
|
|
/// Feed the current state of the bound modifier flag; returns an event only on a transition.
|
|
public mutating func process(isDown: Bool) -> HotkeyEvent? {
|
|
guard isDown != self.isDown else { return nil }
|
|
self.isDown = isDown
|
|
return isDown ? .pressed : .released
|
|
}
|
|
}
|