sindresorhus / KeyboardShortcuts

⌨️ Add user-customizable global keyboard shortcuts (hotkeys) to your macOS app in minutes
https://swiftpackageindex.com/sindresorhus/KeyboardShortcuts/documentation/keyboardshortcuts/keyboardshortcuts
MIT License
1.94k stars 181 forks source link

Add initializer to `KeyboardShortcuts.Recorder` that accepts a binding #164

Open sindresorhus opened 5 months ago

sindresorhus commented 5 months ago

This would let developers use the recorder for custom use-cases when they don't need everything that comes with the Name system. For example, support for local shortcuts.

import SwiftUI
import KeyboardShortcuts

struct SettingsScreen: View {
    @State private var shortcut: KeyboardShortcuts.Shortcut?

    var body: some View {
        Form {
            KeyboardShortcuts.Recorder("Toggle Unicorn Mode:", shortcut: $shortcut)
        }
    }
}

Also document how to use this to be able to use the recorder to record local shortcuts.