---
title: "button(_:)"
framework: uikit
role: symbol
role_heading: Type Method
path: "uikit/uievent/buttonmask-swift.struct/button(_:)"
---

# button(_:)

Creates a button mask from the specified button index.

## Declaration

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

## Parameters

- `buttonNumber`: The index of the button on the input device. Pass 1 to represent doc://com.apple.uikit/documentation/UIKit/UIEvent/ButtonMask-swift.struct/primary, and 2 to represent doc://com.apple.uikit/documentation/UIKit/UIEvent/ButtonMask-swift.struct/secondary.

## See Also

### Creating button masks

- [init(rawValue:)](uikit/uievent/buttonmask-swift.struct/init(rawvalue:).md)
