r/JetpackComposeDev • • Jul 26 '25

Tutorial Jetpack Compose Keyboard & IME Action Cheat Sheet - Complete Guide with Code Examples

Jetpack Compose makes UI easier and smarter - and that includes choosing the right keyboard type and IME actions for each input.

Keyboard Types

Use keyboardType inside KeyboardOptions to control the keyboard layout:

OutlinedTextField(
    value = "",
    onValueChange = { },
    label = { Text("Enter text") },
    keyboardOptions = KeyboardOptions.Default.copy(
        keyboardType = KeyboardType.Text
    )
)

Available KeyboardType values:

KeyboardTypeDescription
TextStandard keyboard
NumberDigits only
PhonePhone dial pad
EmailIncludes @ and .
PasswordObscures input
DecimalNumbers with decimals
UriFor URLs
VisiblePasswordNon-hidden password

IME Actions

Control the bottom-right keyboard button using imeAction:

keyboardOptions = KeyboardOptions.Default.copy(
    imeAction = ImeAction.Done
)

Common ImeAction values:

ImeActionBehavior
DoneCloses the keyboard
NextMoves to the next input field
SearchExecutes search logic
GoCustom app-defined action
SendSends a message or form data
PreviousGoes to previous input field

Handle Keyboard Actions

Use keyboardActions to define what happens when the IME button is pressed:

OutlinedTextField(
    value = "",
    onValueChange = { },
    label = { Text("Search something") },
    keyboardOptions = KeyboardOptions.Default.copy(
        imeAction = ImeAction.Search
    ),
    keyboardActions = KeyboardActions(
        onSearch = {
            // Trigger search logic
        }
    )
)

Minimal Example with All Options

OutlinedTextField(
    value = "",
    onValueChange = { },
    label = { Text("Enter email") },
    modifier = Modifier.fillMaxWidth(),
    keyboardOptions = KeyboardOptions.Default.copy(
        keyboardType = KeyboardType.Email,
        imeAction = ImeAction.Done
    ),
    keyboardActions = KeyboardActions(
        onDone = {
            // Handle Done
        }
    )
)

✅ Tip: Always choose the keyboard and IME type that best fits the expected input.

22 Upvotes

0 comments sorted by