<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSResponder/performKeyEquivalent(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSResponder(im)performKeyEquivalent:"
  },
  "title" : "performKeyEquivalent(with:)"
}
-->

# performKeyEquivalent(with:)

Handle a key equivalent.

```
func performKeyEquivalent(with event: NSEvent) -> Bool
```

## Parameters

`event`

An event object that represents the key equivalent pressed.

## Discussion

Override to handle key equivalents. If the character code or codes in `event` match the receiver’s key equivalent, the receiver should respond to the event and return <doc://com.apple.documentation/documentation/Swift/true>. The default implementation does nothing and returns <doc://com.apple.documentation/documentation/Swift/false>.

> Note:
> ``doc://com.apple.appkit/documentation/AppKit/NSResponder/performKeyEquivalent(with:)`` takes an ``doc://com.apple.appkit/documentation/AppKit/NSEvent`` object as its argument, while ``doc://com.apple.appkit/documentation/AppKit/NSResponder/performMnemonic:`` takes an <doc://com.apple.documentation/documentation/Foundation/NSString> object containing the uninterpreted characters of the key event. You should extract the characters for a key equivalent using the `NSEvent` method  ``doc://com.apple.appkit/documentation/AppKit/NSEvent/charactersIgnoringModifiers``.

## See Also

[`-  performKeyEquivalent:`](/documentation/AppKit/NSView/performKeyEquivalent(with:))

Implemented by subclasses to respond to key equivalents (also known as keyboard shortcuts).

[`-  performKeyEquivalent:`](/documentation/AppKit/NSButton/performKeyEquivalent(with:))

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



---

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)