---
title: "addKeyCommand(_:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiviewcontroller/addkeycommand(_:)"
---

# addKeyCommand(_:)

Associates the specified keyboard shortcut with the view controller.

## Declaration

```swift
func addKeyCommand(_ keyCommand: UIKeyCommand)
```

## Parameters

- `keyCommand`: The key command to add.

## Discussion

Discussion This method lets you easily add key commands to the view controller without overriding the keyCommands property. The key commands you add to a view controller are applied to the active responder chain. When the user performs a key command, UIKit searches the responder chain (starting with the first responder) for an object capable of handling the specified action.

## See Also

### Related Documentation

- [keyCommands](uikit/uiresponder/keycommands.md)

### Accessing the available key commands

- [performsActionsWhilePresentingModally](uikit/uiviewcontroller/performsactionswhilepresentingmodally.md)
- [removeKeyCommand(_:)](uikit/uiviewcontroller/removekeycommand(_:).md)
