Skip to content

KeyboardShortcut modifier #3

@CleverLemming1337

Description

@CleverLemming1337
import SwiftUI

struct ContentView: View {
    @State private var shortcut: String = "a"
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundColor(.accentColor)
            Text("Hello, world!")
            Button("press me") {
                print("Pressed")
            }
            .keyboardShortcut(KeyEquivalent(shortcut.first ?? "a")) // this

            TextField("Shortcut", text: $shortcut)
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions