ShiftKeyUpChecker // Add additional conditions.
This commit is contained in:
parent
9dc1e0aa80
commit
88ccbdf11d
|
@ -31,10 +31,12 @@ public struct ShiftKeyUpChecker {
|
||||||
|
|
||||||
private var lastTime: Date = .init()
|
private var lastTime: Date = .init()
|
||||||
|
|
||||||
|
private var shiftIsBeingPressed = false
|
||||||
|
|
||||||
private mutating func checkModifierKeyUp(event: NSEvent) -> Bool {
|
private mutating func checkModifierKeyUp(event: NSEvent) -> Bool {
|
||||||
if event.type == .flagsChanged,
|
if event.type == .flagsChanged,
|
||||||
event.modifierFlags.intersection(.deviceIndependentFlagsMask) == .init(rawValue: 0),
|
event.modifierFlags.intersection(.deviceIndependentFlagsMask) == .init(rawValue: 0),
|
||||||
Date() - lastTime <= delayInterval
|
Date() - lastTime <= delayInterval, shiftIsBeingPressed
|
||||||
{
|
{
|
||||||
// modifier keyup event
|
// modifier keyup event
|
||||||
lastTime = Date(timeInterval: -3600 * 4, since: Date())
|
lastTime = Date(timeInterval: -3600 * 4, since: Date())
|
||||||
|
@ -54,8 +56,10 @@ public struct ShiftKeyUpChecker {
|
||||||
if isKeyDown {
|
if isKeyDown {
|
||||||
// modifier keydown event
|
// modifier keydown event
|
||||||
lastTime = Date()
|
lastTime = Date()
|
||||||
|
if event.modifierFlags == .shift { shiftIsBeingPressed = true }
|
||||||
} else {
|
} else {
|
||||||
lastTime = Date(timeInterval: -3600 * 4, since: Date())
|
lastTime = Date(timeInterval: -3600 * 4, since: Date())
|
||||||
|
shiftIsBeingPressed = false
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue