---
title: "menuHasKeyEquivalent(_:for:target:action:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsmenudelegate/menuhaskeyequivalent(_:for:target:action:)"
---

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

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

## Declaration

```swift
@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 doc://com.apple.appkit/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

Return Value If there is a valid and enabled menu item that corresponds to this key-down even, return true after specifying the target and action. Return false if there are no items with that key equivalent or if the item is disabled.

## Discussion

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

### Related Documentation

- [performActionForItem(at:)](appkit/nsmenu/performactionforitem(at:).md)
- [performKeyEquivalent(with:)](appkit/nsmenu/performkeyequivalent(with:).md)
