---
title: "performKeyEquivalent(with:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsbutton/performkeyequivalent(with:)"
---

# performKeyEquivalent(with:)

Checks the button’s key equivalent against the specified event and, if they match, simulates the button being clicked.

## Declaration

```swift
func performKeyEquivalent(with key: NSEvent) -> Bool
```

## Parameters

- `key`: The event containing the key equivalent.

## Return Value

Return Value true if the key equivalent in anEvent matches the button’s key equivalent; false if it does not. This method also returns false if the button is blocked by a modal panel or the button is disabled.

## Discussion

Discussion If the character in anEvent matches the button’s key equivalent, and the modifier flags in anEvent match the key-equivalent modifier mask, performKeyEquivalent(with:) simulates the user clicking the button and returning true. Otherwise, performKeyEquivalent(with:) does nothing and returns false.

## See Also

### Related Documentation

- [keyEquivalent](appkit/nsbutton/keyequivalent.md)
- [keyEquivalentModifierMask](appkit/nsbutton/keyequivalentmodifiermask.md)
