---
title: keyEquivalent
framework: appkit
role: symbol
role_heading: Instance Property
path: appkit/nsbutton/keyequivalent
---

# keyEquivalent

The key-equivalent character of the button.

## Declaration

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

## Discussion

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

### Related Documentation

- [performKeyEquivalent(with:)](appkit/nsbutton/performkeyequivalent(with:).md)
- [keyEquivalentFont](appkit/nsbuttoncell/keyequivalentfont.md)

### Accessing key equivalents

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