---
title: "init(input:modifierFlags:action:discoverabilityTitle:)"
framework: uikit
role: symbol
role_heading: Initializer
path: "uikit/uikeycommand/init(input:modifierflags:action:discoverabilitytitle:)"
---

# init(input:modifierFlags:action:discoverabilityTitle:)

Creates a key command object that matches the specified input and has a title.

## Declaration

```swift
convenience init(input: String, modifierFlags: UIKeyModifierFlags, action: Selector, discoverabilityTitle: String)
```

## Parameters

- `input`: The keys that a person must press. The string must contain one or more characters corresponding to the keys a person pressed. For a list of special characters that don’t have a textual representation, see doc://com.apple.uikit/documentation/UIKit/input-strings-for-special-keys.
- `modifierFlags`: The bit mask of modifier keys that a person must press. You can use this parameter to specify which modifier keys (Command, Option, and so on) a person must also press. You may specify more than one modifier key. For a list of possible values, see doc://com.apple.uikit/documentation/UIKit/UIKeyModifierFlags.
- `action`: The action method to execute on the responder object.
- `discoverabilityTitle`: An elaborated title that explains the purpose of the key command.

## Return Value

Return Value The initialized key command object.

## Discussion

Discussion After creating a key command object, you can add it to a view controller using the addKeyCommand(_:) method of the view controller. You can also override any responder class and return the key command directly from the responder’s keyCommands property.
