Compose Unstyled 2.0 is out! Check the official announcement blog ->

Escape Handler

A multiplatform handler for dismissing UI from Escape or Back interactions.

Installation

implementation("com.composables:composeunstyled-escape-handler")

Basic Example

Use EscapeHandler when a visible surface should close from Escape or Back interactions.

var visible by remember { mutableStateOf(false) }

if (visible) {
    EscapeHandler {
        visible = false
    }
}

Usage

EscapeHandler is useful for dismissible surfaces such as dialogs, modals, menus, and custom overlays.