public class KeyboardOptions(
public val capitalization: KeyboardCapitalization = KeyboardCapitalization.Unspecified,
public val autoCorrectEnabled: Boolean? = null,
public val keyboardType: KeyboardType = KeyboardType.Unspecified,
public val imeAction: ImeAction = ImeAction.Unspecified,
public val platformImeOptions: PlatformImeOptions? = null,
public val showKeyboardOnFocus: Boolean? = null,
@get:Suppress("NullableCollection") public val hintLocales: LocaleList? = null,
)
Defines keyboard configuration options for TextFields.
Represents specific layout, capitalization, and system action hints sent to the Input Method Editor (IME/software keyboard) on focus gain.
Soft keyboards make best-effort attempts to comply with the options provided here. Key layouts and flag behaviors are ultimately determined by the active IME implementation.
Parameters
| capitalization | informs the keyboard whether to automatically capitalize characters, words, or sentences. Only applicable to text-based KeyboardTypes such as KeyboardType.Text, KeyboardType.Ascii, or KeyboardType.PostalAddress. It is ignored by soft keyboards when paired with numeric layouts (like KeyboardType.Number or KeyboardType.Decimal). |
| autoCorrectEnabled | informs the keyboard whether to enable auto-correct suggestions. Only applicable to text-based KeyboardTypes such as KeyboardType.Text, KeyboardType.Email, or KeyboardType.Uri. Keyboards ignore this value for numeric keypads. A null value (the default parameter value) expresses that soft keyboard default configurations should apply. |
| keyboardType | keyboard keypad layout to be displayed in the focused text field. Honored by keyboards to display tailored key selections (e.g., phone dialer characters for KeyboardType.Phone, decimal separator buttons for KeyboardType.Decimal, or masked numeric pads for KeyboardType.NumberPassword). |
| imeAction | action button displayed on the soft keyboard (e.g., search, send, next, done, etc.). This action is honored by the software keyboard and may display custom icons (like a magnifying glass for ImeAction.Search). When the text field allows multi-line inputs, the keyboard typically displays a return key instead of the action icon requested here. |
| platformImeOptions | platform-specific IME options (like private IME commands). |
| showKeyboardOnFocus | when true, the soft keyboard shows immediately on text field focus gain. When false, the soft keyboard is hidden until the user taps the text field. A null value (the default parameter value) enables showing the keyboard automatically on focus gain. Note: This option is only supported by TextFieldState-based TextFields (like BasicTextField) and is ignored by legacy TextFields. |
| hintLocales | list of languages for IMEs. Provides a localized hint to help multilingual keyboards automatically shift their keyboard language based on the active field's context. |
Properties
autoCorrect
@Deprecated("Please use the autoCorrectEnabled property.", level = DeprecationLevel.WARNING)
public val autoCorrect: Boolean
shouldShowKeyboardOnFocus
@Deprecated(
"Included for binary compatibility. Use showKeyboardOnFocus.",
level = DeprecationLevel.HIDDEN,
)
public val shouldShowKeyboardOnFocus: Boolean
Functions
copy
public fun copy(
capitalization: KeyboardCapitalization = this.capitalization,
@Suppress("AutoBoxing") autoCorrectEnabled: Boolean? = this.autoCorrectEnabled,
keyboardType: KeyboardType = this.keyboardType,
imeAction: ImeAction = this.imeAction,
platformImeOptions: PlatformImeOptions? = this.platformImeOptions,
@Suppress("AutoBoxing") showKeyboardOnFocus: Boolean? = null,
hintLocales: LocaleList? = null,
): KeyboardOptions
Returns a copy of this object with the values passed to this method.
Note that if an unspecified (null) value is passed explicitly to this method, it will replace any actually-specified value. This differs from the behavior of merge, which will never take an unspecified value over a specified one.
copy
@Deprecated(
"Please use the copy function that takes an autoCorrectEnabled parameter.",
level = DeprecationLevel.HIDDEN,
replaceWith =
ReplaceWith(
"copy(" +
"capitalization = capitalization, " +
"autoCorrectEnabled = autoCorrect, " +
"keyboardType = keyboardType, " +
"imeAction = imeAction," +
"platformImeOptions = platformImeOptions, " +
"showKeyboardOnFocus = showKeyboardOnFocus ?: true," +
"hintLocales = hintLocales" +
")"
),
)
public fun copy(
capitalization: KeyboardCapitalization = this.capitalization,
autoCorrect: Boolean = this.autoCorrectOrDefault,
keyboardType: KeyboardType = this.keyboardType,
imeAction: ImeAction = this.imeAction,
platformImeOptions: PlatformImeOptions? = this.platformImeOptions,
@Suppress("AutoBoxing") showKeyboardOnFocus: Boolean? = this.showKeyboardOnFocusOrDefault,
hintLocales: LocaleList? = this.hintLocales,
): KeyboardOptions
copy
@Deprecated("Maintained for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun copy(
capitalization: KeyboardCapitalization = this.capitalization,
autoCorrect: Boolean = this.autoCorrectOrDefault,
keyboardType: KeyboardType = this.keyboardType,
imeAction: ImeAction = this.imeAction,
platformImeOptions: PlatformImeOptions? = this.platformImeOptions,
): KeyboardOptions
copy
@Deprecated(
"Please use the new copy function that takes optional platformImeOptions parameter.",
level = DeprecationLevel.HIDDEN,
)
public fun copy(
capitalization: KeyboardCapitalization = this.capitalization,
autoCorrect: Boolean = this.autoCorrectOrDefault,
keyboardType: KeyboardType = this.keyboardType,
imeAction: ImeAction = this.imeAction,
): KeyboardOptions
equals
override fun equals(other: Any?): Boolean
hashCode
override fun hashCode(): Int
toString
override fun toString(): String
merge
public fun merge(other: KeyboardOptions?): KeyboardOptions
Returns a new KeyboardOptions that is a combination of this options and a given other options.
others null or Unspecified properties are replaced with the non-null properties of this object.
If the either this or other is null, returns the non-null one.
Members
Companion
public companion object
Properties
Default
@Stable public val Default: KeyboardOptions = KeyboardOptions()
Provides default KeyboardOptions. See parameter descriptions for default values.