I have a column of TextFields, something like:
Column {
TextField(
value = ...,
onValueChange = { ... },
keyboardOptions = KeyboardOptions(imeAction = ImeAction.next),
)
TextField(
value = ...,
onValueChange = { ... },
keyboardOptions = KeyboardOptions(imeAction = ImeAction.next),
)
.
.
.
}
I would like to have the focus on each TextField move to the next when the user press Tab, or the next button on the keyboard. Currently pressing Tab inserts a tab into the TextField. Pressing the next button does nothing. I can create a FocusRequester for each TextField and set the keyboardActions onNext to request focus on the next field for each one. This is a little tedious and it doesn't address the Tab behavior.
it.key.keyCode == Key.Tab.keyCode
you can simply doit.key == Key.Tab
, however if you want to avoid the experimental API opt-in you can instead doit.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_TAB
. Also, it's better to useModifier.onPreviewKeyEvent
sinceModifier.onKeyEvent
callsonValueChange
before propagating the key event, so you could end up in situations where the TextField you just tabbed out of now has an extra tab character that the user isn't aware of. – Nobility