NSEventImpl // Add KeyCode.toEvent().

This commit is contained in:
ShikiSuen 2023-06-24 16:23:27 +08:00
parent 1fabd619e0
commit 2bfb29aea4
1 changed files with 9 additions and 0 deletions

View File

@ -250,6 +250,15 @@ public enum KeyCode: UInt16 {
case kRightArrow = 124 case kRightArrow = 124
case kDownArrow = 125 case kDownArrow = 125
case kUpArrow = 126 case kUpArrow = 126
public func toEvent() -> NSEvent? {
NSEvent.keyEvent(
with: .keyDown, location: .zero, modifierFlags: [],
timestamp: TimeInterval(), windowNumber: 0, context: nil,
characters: "", charactersIgnoringModifiers: "",
isARepeat: false, keyCode: rawValue
)
}
} }
enum KeyCodeBlackListed: UInt16 { enum KeyCodeBlackListed: UInt16 {