Input keyboard type - Android
In Jetpack Compose, you can set a keyboard type by using the KeyboardType
class in keyboardOptions
property of TextField
.
The following constants are defined for KeyboardType
:
Ascii
: for entering ASCII charactersDecimal
: for entering decimalsEmail
: for entering email addressesNumber
: for entering digitsNumberPassword
: for entering number passwordPassword
: for entering passwordPhone
: for entering phone numbersText
: for entering regular textUnspecified
: default keyboard typeUri
: for entering URIs
Example of using KeyboardType
:
TextField(
value = "",
onValueChange = { /* State update logic */ },
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number)
)