---
title: "textFieldShouldReturn(_:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextfielddelegate/textfieldshouldreturn(_:)"
---

# textFieldShouldReturn(_:)

Asks the delegate whether to process the pressing of the Return button for the text field.

## Declaration

```swift
optional func textFieldShouldReturn(_ textField: UITextField) -> Bool
```

## Parameters

- `textField`: The text field whose return button was pressed.

## Return Value

Return Value true if the text field should implement its default behavior for the return button; otherwise, false.

## Discussion

Discussion The text field calls this method whenever the user taps the return button. You can use this method to implement any custom behavior when the button is tapped. For example, if you want to dismiss the keyboard when the user taps the return button, your implementation can call the resignFirstResponder() method.

## See Also

### Editing the text field’s text

- [textField(_:shouldChangeCharactersIn:replacementString:)](uikit/uitextfielddelegate/textfield(_:shouldchangecharactersin:replacementstring:).md)
- [textFieldShouldClear(_:)](uikit/uitextfielddelegate/textfieldshouldclear(_:).md)
