From a0afaa6a541cac07674b2f4c44514fd205eb27b8 Mon Sep 17 00:00:00 2001 From: Jordan Baird Date: Sun, 1 May 2022 11:25:45 -0600 Subject: [PATCH] Refactoring --- Sources/SwiftKeys/Key.swift | 4 +--- Sources/SwiftKeys/KeyEvent.swift | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Sources/SwiftKeys/Key.swift b/Sources/SwiftKeys/Key.swift index 9e2b61c..e60f09b 100644 --- a/Sources/SwiftKeys/Key.swift +++ b/Sources/SwiftKeys/Key.swift @@ -245,7 +245,7 @@ extension KeyEvent { /// The Kana key that is available on JIS keyboards. case jisKana - // MARK: - Raw Value + // MARK: - Properties /// The raw value of the key. public var rawValue: Int { @@ -361,8 +361,6 @@ extension KeyEvent { } } - // MARK: - String Value - /// A string representation of the key. public var stringValue: String { switch self { diff --git a/Sources/SwiftKeys/KeyEvent.swift b/Sources/SwiftKeys/KeyEvent.swift index f5c1e17..4ae63d3 100644 --- a/Sources/SwiftKeys/KeyEvent.swift +++ b/Sources/SwiftKeys/KeyEvent.swift @@ -85,6 +85,9 @@ public struct KeyEvent { static var keyEventStorage = [Name: KeyEvent]() static var proxyStorage = [Name: EventProxy]() + /// The name that is be used to store this key event. + public let name: Name + /// The key associated with this key event. public var key: Key? { proxy.key @@ -95,9 +98,6 @@ public struct KeyEvent { proxy.modifiers } - /// The name that is be used to store this key event. - public let name: Name - var proxy: EventProxy { if let proxy = Self.proxyStorage[name] { return proxy @@ -108,7 +108,7 @@ public struct KeyEvent { } } - // Implementation detail: + // Implementation. private init?(_name: Name) { if let data = UserDefaults.standard.data(forKey: _name.combinedValue),