@ -8,7 +8,7 @@ This tutorial expects that you have already set up the Compose project as descri
In this tutorial, we will look at two different ways of handling keyboard events in Compose for Desktop as well as the utilities that we have to do this.
In this tutorial, we will look at two different ways of handling keyboard events in Compose for Desktop as well as the utilities that we have to do this.
## KeySets& ShortcutHandler
## KeySets
Compose for Desktop has a few utilities to work with shortcuts:
Compose for Desktop has a few utilities to work with shortcuts:
@ -18,8 +18,6 @@ Compose for Desktop has a few utilities to work with shortcuts:
Key.CtrlLeft + Key.Enter
Key.CtrlLeft + Key.Enter
```
```
`ShortcutHandler` accepts `KeysSet` and returns a handler which could be used as a callback for `keyInputFilter`
## Event handlers
## Event handlers
There are two ways to handle key events in Compose for Desktop:
There are two ways to handle key events in Compose for Desktop:
@ -31,6 +29,8 @@ There are two ways to handle key events in Compose for Desktop:
It works the same as Compose for Android, see for details [API Reference](https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/package-summary#keyinputfilter)
It works the same as Compose for Android, see for details [API Reference](https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/package-summary#keyinputfilter)
`Modifier.shortcuts` is used to define one or multiple callbacks for `KeysSet`s.
The most common use case is to define keyboard handlers for active controls like `TextField`. Here is an example:
The most common use case is to define keyboard handlers for active controls like `TextField`. Here is an example: