Jetpack Compose Tidbits — Series I: Text input — Part IV — Keyboard Options

Tashinga Pemhiwa
2 min readAug 22, 2023

--

Previously in this series on Text input in Jetpack Compose, we have discussed what a TextField is, and even how to create a password field.

KeyboardOptions control how the soft keyboard behaves. Here are the available parameters:

capitalization — causes the keyboard to capitalize text (or disables text capitalization), allowing you to capitalize each character, each word, each sentence in the textfield, or nothing at all.

autocorrect — enables or disables autocorrect.

keyboardType — controls the appearance of the soft keyboard (e.g. setting it for number entry or for email entry). Some examples below, with screenshots.

Here is how to make use of this parameter:

TextField(
value = password,
onValueChange = { name = it },
label = { Text(text = "Name") },
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Go,
keyboardType = KeyboardType.Text,
capitalization = KeyboardCapitalization.Words,
autoCorrect = false
),
)

KeyboardType.Number

imeActionprovides button actions on the keyboard, such as “Done”, “Next” or “Search”. The default action is “Default”, which provides the ‘Enter key’ button as shown at the bottom right of the screenshot below:

Some of the other imeActions available are:

ImeAction.Search:

ImeAction.Go:

ImeAction.Done:

ImeAction.Next:

#Extra marks

The remaining imeActions are ImeActions.None, ImeActions.Previous and ImeActions.Send. Play around with them and see how your soft keyboard behaves.

--

--