input keyboard actions

Flutter tips Published on

Making forms easy to fill out is super important for your app users. One great way to help them is by using input actions on the keyboard. This lets users quickly move between fields without needing to tap the screen.

Speed up Form Filling

Imagine you have an email and password field. After typing the email, your user probably wants to go straight to the password field. Instead of seeing a standard 'done' or 'return' key, you can show a 'next' key on the keyboard.

How it Works

You tell the text field what action should appear on the keyboard when the user is typing in it. For the email field, you'd set it to 'next'.

Binding Actions

Once the user presses the 'next' key (or submits the field in some way), you can tell your app what to do. This is usually done in the onFieldSubmitted part of your text field.

Example Action Flow

In the onFieldSubmitted callback for the email field, you can make two things happen:

  1. Unfocus the current field: This removes the keyboard from the screen or just takes the cursor out of the email box.
  2. Focus the next field: This moves the cursor into the password field, making the keyboard ready for the next input.

Using FocusNode helps you manage which field is currently active or focused.

Save 3 months of work

Create your app using our 6 years of making Flutter apps and more than 50+ apps

kickstarter for flutter apps

Frequently Asked Questions

What are input keyboard actions?

They are special buttons or actions shown on the user's on-screen keyboard, like 'next', 'done', 'search', etc., that help users complete tasks related to text input.

How do these actions help users?

They make filling out forms faster and more convenient by allowing users to move between fields or submit forms directly from the keyboard.

How do I set the action?

You use the `textInputAction` property on your text input widget (like `TextFormField`) and set it to a value from `TextInputAction`, such as `TextInputAction.next`.

What happens when the action key is pressed?

When the user presses the action key, the `onFieldSubmitted` callback of the text field is triggered. You can put your code here to handle what happens next, like moving to the next field.

How do I move focus to the next field?

You need a `FocusNode` for each field. In the `onFieldSubmitted` of the current field, you first call `unfocus()` on its `FocusNode` and then call `requestFocus()` on the `FocusNode` of the next field using `FocusScope`.

Read more
You may also be interested in
Delegate widget design  blog card image
Delegate widget design
Published on 2025-05-12T09:03:59.853Z
Listen keyboard visibility state  blog card image
Listen keyboard visibility state
Published on 2025-05-12T09:22:43.829Z
ApparenceKit is a flutter template generator tool by Apparence.io © 2025.
All rights reserved