Skip to content

Instantly share code, notes, and snippets.

@jaredmdobson
Created May 25, 2022 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredmdobson/1b114c0c2cf1b1fb88b5cc03edd4eb1e to your computer and use it in GitHub Desktop.
Save jaredmdobson/1b114c0c2cf1b1fb88b5cc03edd4eb1e to your computer and use it in GitHub Desktop.
Prevent DEL Button crashing on jetpack compose android textfield
@Composable
fun SafeTextField(modifier = Modifier){
TextField(
modifier = modifier.onPreviewKeyEvent {
it.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DEL
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment