File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Sources/KeyboardShortcuts Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -752,9 +752,23 @@ extension KeyboardShortcuts.Shortcut: CustomStringConvertible {
752752}
753753
754754extension KeyboardShortcuts . Shortcut {
755+ /**
756+ Converts this shortcut to a SwiftUI `KeyboardShortcut`.
757+
758+ Use this to apply a user-defined shortcut to a SwiftUI view using the `.keyboardShortcut(_:)` modifier.
759+
760+ Returns `nil` if the shortcut cannot be represented in SwiftUI (for example, certain special keys).
761+
762+ ```swift
763+ Button("Perform Action") {
764+ performAction()
765+ }
766+ .keyboardShortcut(shortcut.toSwiftUI)
767+ ```
768+ */
755769 @available ( macOS 11 , * )
756770 @MainActor
757- var toSwiftUI : KeyboardShortcut ? {
771+ public var toSwiftUI : KeyboardShortcut ? {
758772 if
759773 let key,
760774 let specialKey = keyToSpecialKeyMapping [ key]
You can’t perform that action at this time.
0 commit comments