Keyboard shortcuts
iliasaz opened this issue · 2 comments
iliasaz commented
Hello,
Thanks for this great library!
A beginner's question: what's the easiest way to add keyboard shortcuts? I'd like to execute a closure upon receiving a specific keyboard combination, ex. Cmd-R.
Thanks!
helje5 commented
Hi, Apple has a wealth of information about SwiftUI readily available:
https://developer.apple.com/videos/
An example from one of my own apps, HMScriptEditor:
Button(action: run) {
Label("Run", systemImage: "play.fill")
}
.help("Run the HomeMatic script on the base station")
.keyboardShortcut("r", modifiers: .command)
iliasaz commented
oh, this is much easier than I thought. Thank you so much!