<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSButton/keyEquivalent",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSButton(py)keyEquivalent"
  },
  "title" : "keyEquivalent"
}
-->

# keyEquivalent

The key-equivalent character of the button.

```
var keyEquivalent: String { get set }
```

## Discussion

This property contains the button’s key equivalent, or the empty string if no equivalent has been defined. Buttons don’t have a default key equivalent.

If you set a key equivalent instead of an image, the button’s interior is redrawn. However, the key equivalent isn’t displayed if the image position is set to `NSNoImage`, `NSImageOnly`, or `NSImageOverlaps`; that is, the button must display both its title and its “image” (which is the key equivalent in this case), and they must not overlap.

To display a key equivalent on a button, set the image and alternate image to `nil`, set the key equivalent, and then set the image position.

## See Also

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

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

[`keyEquivalentFont`](/documentation/AppKit/NSButtonCell/keyEquivalentFont)

The font used to draw the button’s 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)