<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSMenuDelegate/menuHasKeyEquivalent(_:for:target:action:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSMenuDelegate(im)menuHasKeyEquivalent:forEvent:target:action:"
  },
  "title" : "menuHasKeyEquivalent(_:for:target:action:)"
}
-->

# menuHasKeyEquivalent(_:for:target:action:)

Invoked to allow the delegate to return the target and action for a key-down event.

```
@MainActor optional func menuHasKeyEquivalent(_ menu: NSMenu, for event: NSEvent, target: AutoreleasingUnsafeMutablePointer<AnyObject?>, action: UnsafeMutablePointer<Selector?>) -> Bool
```

## Parameters

`menu`

The menu object sending the delegation message.

`event`

An [`NSEvent`](/documentation/AppKit/NSEvent) object representing a key-down event.

`target`

Return by reference the target object for the menu item that corresponds to the event. Specify `nil` to request the menu’s target.

`action`

Return by reference the action selector for the menu item that corresponds to the event.

## Return Value

If there is a valid and enabled menu item that corresponds to this key-down even, return <doc://com.apple.documentation/documentation/Swift/true> after specifying the target and action. Return <doc://com.apple.documentation/documentation/Swift/false> if there are no items with that key equivalent or if the item is disabled.

## Discussion

If the delegate doesn’t define this method, the menu is populated to find out if any items have a matching key equivalent.

## See Also

[`func performActionForItem(at: Int)`](/documentation/AppKit/NSMenu/performActionForItem(at:))

Causes the application to send the action message of a specified menu item to its target.

[`func performKeyEquivalent(with: NSEvent) -> Bool`](/documentation/AppKit/NSMenu/performKeyEquivalent(with:))

Performs the action for the menu item that corresponds to the given key equivalent.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)