Skip to main content

Overview

The IQKeyboardReturnManager subspec provides automatic return key handling, allowing users to navigate between text fields by pressing the Return key on the keyboard. The manager automatically changes the return key type to “Next” or “Done” based on the field’s position in the form.
IQKeyboardReturnManager is now available as an independent library, similar to IQKeyboardToolbarManager.

Installation

CocoaPods

Podfile

Swift Package Manager

The IQKeyboardReturnManager is included in the main package or can be added separately:

How It Works

The Return Key Manager automatically:
  1. Detects text field order in your form
  2. Changes return key type to “Next” for fields with a next field
  3. Changes return key type to “Done” for the last field
  4. Handles return key taps to move to the next field or dismiss keyboard
  5. Works with UITextField and UITextView

Basic Setup

Return key handling works automatically once IQKeyboardManager is enabled:
AppDelegate.swift
No additional configuration is needed. Return key handling is enabled by default when IQKeyboardManager is active.

Return Key Types

The manager automatically sets appropriate return key types:

Next

Used for fields that have a next text field in the form

Done

Used for the last text field to dismiss the keyboard
ViewController.swift
When the user:
  1. Taps Return on firstNameField → moves to lastNameField
  2. Taps Return on lastNameField → moves to emailField
  3. Taps Return on emailField → moves to passwordField
  4. Taps Return on passwordField → dismisses keyboard

Manual Return Key Control

You can still manually set return key types when needed:
ViewController.swift
Manually set return key types will be respected by IQKeyboardManager.

Custom Return Key Actions

Implement UITextFieldDelegate to customize behavior:
ViewController.swift

UITextView Support

For multi-line text views, the manager handles return keys intelligently:
ViewController.swift
Setting returnKeyType = .next on a UITextView will make the Return key advance to the next field instead of inserting a line break.

Handling Special Cases

Search Fields

ViewController.swift

Submit Forms

ViewController.swift

Disable Return Key Handling

If you want to disable automatic return key handling while keeping other IQKeyboardManager features:
AppDelegate.swift
The return key manager is lightweight and non-intrusive. It only changes return key types and doesn’t interfere with custom UITextFieldDelegate implementations.

Return Key vs Toolbar Navigation

Return Key Navigation

Advantages:
  • Natural typing flow
  • No additional UI
  • Familiar to users
  • Works great for short forms
Disadvantages:
  • Less discoverable
  • No previous button
  • Requires pressing return

Toolbar Navigation

Advantages:
  • Visible Previous/Next/Done buttons
  • Can go back to previous fields
  • More discoverable
  • Better for long forms
Disadvantages:
  • Takes up space above keyboard
  • Additional UI element
You can use both return key handling and toolbar navigation together for maximum flexibility.

Combined Example

CompleteFormViewController.swift

Best Practices

Unless you have specific requirements, let IQKeyboardManager automatically configure return key types. It’s smart enough to handle most scenarios.
Set returnKeyType = .search for search fields to show the search icon instead of “Next” or “Done”.
For fields that need line breaks (like comments or notes), use .default return key type. For single-line behavior, use .next or .done.
Always test the complete navigation flow to ensure users can easily move through your form using the Return key.

Troubleshooting

  • Verify IQKeyboardManager is enabled
  • Check if you’ve implemented textFieldShouldReturn that returns false
  • Ensure text fields are in the view hierarchy
  • Check that next field is a valid text input view
  • Check if you’ve manually set returnKeyType
  • Verify the field order in your view hierarchy
  • Try reloading the keyboard: textField.reloadInputViews()
  • Check if the field is detected as the last field
  • Verify all text fields are properly connected
  • Ensure hidden fields are actually visible when needed

Next Steps

Toolbar Management

Add Previous/Next/Done buttons for additional navigation

Resign Keyboard

Dismiss keyboard by tapping outside text fields

Advanced Configuration

Fine-tune keyboard behavior

Debugging

Troubleshoot return key issues