<!--
{
  "availability" : [
    "iOS: 13.4.0 -",
    "iPadOS: 13.4.0 -",
    "macCatalyst: 13.4.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIEvent/ButtonMask-swift.struct/button(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:@F@UIEventButtonMaskForButtonNumber"
  },
  "title" : "button(_:)"
}
-->

# button(_:)

Creates a button mask from the specified button index.

```
static func button(_ buttonNumber: Int) -> UIEvent.ButtonMask
```

## Parameters

`buttonNumber`

The index of the button on the input device. Pass `1` to represent [`primary`](/documentation/UIKit/UIEvent/ButtonMask-swift.struct/primary), and `2` to represent [`secondary`](/documentation/UIKit/UIEvent/ButtonMask-swift.struct/secondary).

---

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)