This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreGraphics | |
extension CGKeyCode | |
{ | |
/* | |
* From Events.h in Carbon.framework | |
* Summary: | |
* Virtual keycodes | |
* | |
* Discussion: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
extension CGKeyCode | |
{ | |
// Define whatever key codes you want to detect here | |
static let kVK_Space: CGKeyCode = 0x31 | |
var isPressed: Bool { | |
CGEventSource.keyState(.combinedSessionState, key: self) | |
} |