KeyboardKit
KeyboardKit copied to clipboard
Add extensions for SwiftUI's `KeyboardShortcut`
Add extensions on SwiftUI's KeyboardShortcut
with common keyboard shortcuts, based on those already defined as part of KeyboardBarButtonItem
and elsewhere elsewhere in KeyboardKit.
It seems difficult to provide much utility for SwiftUI compared to what exists for UIKit at the moment, but I thought this might be useful at the very least.
For some background, SwiftUI has .keyboardShortcut
view modifier out-of-the-box that takes either a KeyboardShortcut
or a KeyEquivalent
(key without modifier), but this modifier can only be applied to a Button
or Toggle
to perform their existing action. KeyboardShortcut
only has two existing defined cases for cancelAction
(escape) and defaultAction
(enter).