Setting the keyboard type for input fields helps user entering data. For example, if users need to enter a number, it helps to show a numeric keyboard. If users need to enter an e-mail address, it helps if the at-key (@
) is shown. You should always set an appropriate keyboard type.
Relates to 1.3.5
On Android, you can set a keyboard type by using the android:inputType
property. You can combine values with each other.
The following constants are defined:
date
: for entering a datedatetime
: for entering a date and timenone
: to disable inputnumber
: for entering a numbernumberDecimal
: for entering decimal numbersnumberPassword
: for entering a numeric passwordnumberSigned
: for entering a positive or negative numberphone
: for entering a telephone numbertext
: for entering normal texttextAutoComplete
: to enable automatic completiontextAutoCorrect
: to enable automatic correctiontextCapCharacters
: to automatically convert characters to uppercasetextCapSentences
: to automatically capitalize sentencestextCapWords
: to automatically capitalize wordstextEmailAddress
: for entering an email addresstextEmailSubject
: for entering the subject of an emailtextFilter
: for entering text to filter withtextImeMultiLine
: to force entering multiple lines of texttextLongMessage
: for entering a long messagetextMultiLine
: for entering multiple lines of texttextNoSuggestions
: to disable suggestionstextPassword
: for entering a passwordtextPersonName
: for entering a nametextPhonetic
: for entering phonetic texttextPostalAddress
: for entering a postal addresstextShortMessage
: for entering a short messagetextUri
: for entering a URLtextVisiblePassword
: for entering a visible passwordtextWebEditText
: for entering text in a web formtextWebEmailAddress
: for entering an email address in a web formtextWebPassword
: for entering a password in a web formtime
: for entering a time
Example of using inputType
:
<EditText
android:inputType="text|textMultiLine|textCapSentences" />
On iOS, you can set a keyboard type by using the keyboardType
property.
The following types are defined:
asciiCapable
: a keyboard that displays standard ASCII charactersasciiCapableNumberPad
: a number pad that outputs only ASCII digitsdecimalPad
: a keyboard with numbers and a decimal pointdefault
: the default keyboardemailAddress
: a keyboard for entering email addressesnamePhonePad
: a keypad for entering a person’s name or phone numbernumberPad
: a numeric keypad for PIN entrynumbersAndPunctuation
: a keyboard for numbers and punctuationphonePad
: a keypad for entering telephone numbersURL
: a keyboard for URL entrytwitter
: a keyboard for Twitter text entry, with easy access to the at '@
' and hash '#
' characterswebSearch
: a keyboard for web search terms and URL entry
Example of using keyboardType
:
usernameField.keyboardType = .numberPad
In Flutter, you can set a keyboard type by using the keyboardType
property.
The following values are defined in TextInputType
:
datetime
: Keyboard optimized for entering date and time, iOS displays default keyboard.emailAddress
: Keyboard optimized for entering e-mail addresses.multiline
: Optimized for multiline text input, by having an enter key.name
: Keyboard optimized for inputting a person's namenone
: Prevents the OS from displaying a keyboard.number
: Optimized for unsigned numerical input.phone
: Number keyboard with '*
' and '#
'.streetAddress
: Optimized for entering addresses, iOS displays default keyboard.text
: Optimized for text input.url
: Optimized keyboard for entering URLs with '/
' and '.
'.visiblePassword
: Keyboard with letters and numbers.
Example of using keyboardType
:
TextField(
keyboardType: TextInputType.emailAddress,
)
In React Native, you can set a keyboard type by using the keyboardType
property.
The following values work across platforms:
default
number-pad
decimal-pad
numeric
email-address
phone-pad
url
The following values work on iOS only:
ascii-capable
numbers-and-punctuation
name-phone-pad
twitter
web-search
The following values work on Android only:
visible-password
<TextInput keyboardType="email-address" />
In Xamarin.Forms, you can set a keyboard type by using the Keyboard
property.
The following Keyboard properties
are defined:
Chat
: keyboard for chatting, includesemoji
Default
: default keyboardEmail
: keyboard for entering an e-mail, includes@
Numeric
: keyboard for entering numbers, includes,
and.
Plain
: keyboard for entering plain textTelephone
: keyboard for entering phone numbers, includesplus
andhash
Text
: keyboard for entering text, includesenter
Url
: keyboard for entering url's, includes/
<Editor Keyboard="Email" />