---
title: "onExitCommand(perform:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/onexitcommand(perform:)"
---

# onExitCommand(perform:)

Sets up an action that triggers in response to receiving the exit command while the view has focus.

## Declaration

```swift
nonisolated func onExitCommand(perform action: (() -> Void)?) -> some View

```

## Discussion

Discussion The user generates an exit command by pressing the Menu button on tvOS, or the escape key on macOS.

## See Also

### Responding to commands

- [onMoveCommand(perform:)](swiftui/view/onmovecommand(perform:).md)
- [onDeleteCommand(perform:)](swiftui/view/ondeletecommand(perform:).md)
- [pageCommand(value:in:step:)](swiftui/view/pagecommand(value:in:step:).md)
- [onPlayPauseCommand(perform:)](swiftui/view/onplaypausecommand(perform:).md)
- [onCommand(_:perform:)](swiftui/view/oncommand(_:perform:).md)
- [MoveCommandDirection](swiftui/movecommanddirection.md)
