Search code examples
swiftmacosswiftuikeyboard-shortcuts

SwiftUI - Help Menu KeyboardShortcut Missing


All of my keyboard shortcuts show up in the menus as they should except for the help menu. The keyboard shortcut still works and does show in the menu once I've used the shortcut, but does not show by default as it should.

Xcode 14.3.1 building for 13.3.

Here's the stripped down code just showing the help menu.

@main
struct MyApp: App {

    init() {
        NSWindow.allowsAutomaticWindowTabbing = false
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
        .commands {
            CommandGroup(replacing: .help) {

                Button {
                    NSWorkspace.shared.open(URL(string: "https://www.example.com")!)
                } label: {
                    Text("MyApp Help")
                }
                .keyboardShortcut("H")
            }
        }
    }
}

Solution

  • ⌘H is already used by the system in a previous menu ("Hide ____"), so it's likely not showing up because of the collision.

    enter image description here

    If you switch it to something that isn't taken yet, it shows up fine.

    enter image description here