TextInputAction
The action button of the onscreen keyboard, and what pressing it or Enter does.
Each action lists the mobile platforms whose keyboards support it. In debug builds on Android and iOS, such as an app running on the iOS Simulator, a field with an action that the platform doesn't support gets focus without showing the keyboard, and no error is reported. On Android, release builds show the keyboard with its default action button instead.
Inherits: enum.Enum
Properties
CONTINUE_ACTION- Continues to the next step, such as the next page of a sign-up flow.DONE- The user is done entering input, such as at the end of a form.EMERGENCY_CALL- Calls emergency services.GO- Takes the user to the destination they typed, such as a URL.JOIN- Joins something, such as a wireless network.NEWLINE- Inserts a new line into a multiline field.NEXT- Moves focus to the next focusable control, keeping the keyboard open when it's another text field.NONE- No action specific to the field; the platform decides how the keyboard looks.PREVIOUS- Moves focus to the previous focusable control, keeping the keyboard open when it's another text field.ROUTE- Shows routing options, such as driving directions.SEARCH- Runs a search for the typed text.SEND- Sends what the user typed, such as a message.UNSPECIFIED- Lets the platform choose the most appropriate action.
Examples
Keyboard actions
Set text_input_action to choose the action button of the onscreen keyboard.
Here, the keyboard's Next button moves from one field to the next while the keyboard stays open, and its Send button on the last field calls on_submit. On desktop and web, Enter does the same.
import flet as ft
def main(page: ft.Page):
def send(e: ft.Event[ft.TextField]):
status.value = f"Sent from {name.value} <{email.value}>: {message.value}"
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
name := ft.TextField(
key="name",
label="Name",
text_input_action=ft.TextInputAction.NEXT,
),
email := ft.TextField(
key="email",
label="Email",
keyboard_type=ft.KeyboardType.EMAIL,
text_input_action=ft.TextInputAction.NEXT,
),
message := ft.TextField(
key="message",
label="Message",
text_input_action=ft.TextInputAction.SEND,
on_submit=send,
),
status := ft.Text(),
],
),
),
)
if __name__ == "__main__":
ft.run(main)
Properties
CONTINUE_ACTIONclass-attributeinstance-attribute
Continues to the next step, such as the next page of a sign-up flow.
Doesn't move focus: the field keeps it, so the keyboard stays open.
Supported on iOS only.
DONEclass-attributeinstance-attribute
The user is done entering input, such as at the end of a form.
Removes focus from the field, which closes the keyboard.
Supported on Android and iOS.
EMERGENCY_CALLclass-attributeinstance-attribute
Calls emergency services.
Keeps focus in the field, so the keyboard stays open.
Supported on iOS only.
GOclass-attributeinstance-attribute
Takes the user to the destination they typed, such as a URL.
Removes focus from the field, which closes the keyboard.
Supported on Android and iOS.
JOINclass-attributeinstance-attribute
Joins something, such as a wireless network.
Keeps focus in the field, so the keyboard stays open.
Supported on iOS only.
NEWLINEclass-attributeinstance-attribute
Inserts a new line into a multiline field.
On a single-line field, it removes focus from the field like DONE.
Supported on Android and iOS.
NEXTclass-attributeinstance-attribute
Moves focus to the next focusable control, keeping the keyboard open when it's another text field.
Supported on Android and iOS.
NONEclass-attributeinstance-attribute
No action specific to the field; the platform decides how the keyboard looks.
Keeps focus in the field, so the keyboard stays open.
Supported on Android only.
PREVIOUSclass-attributeinstance-attribute
Moves focus to the previous focusable control, keeping the keyboard open when it's another text field.
Supported on Android only.
ROUTEclass-attributeinstance-attribute
Shows routing options, such as driving directions.
Keeps focus in the field, so the keyboard stays open.
Supported on iOS only.
SEARCHclass-attributeinstance-attribute
Runs a search for the typed text.
Removes focus from the field, which closes the keyboard.
Supported on Android and iOS.
SENDclass-attributeinstance-attribute
Sends what the user typed, such as a message.
Removes focus from the field, which closes the keyboard.
Supported on Android and iOS.
UNSPECIFIEDclass-attributeinstance-attribute
Lets the platform choose the most appropriate action.
Keeps focus in the field, so the keyboard stays open.
Supported on Android and iOS.