Compose for Desktop has a few utilities to work with shortcuts:
`KeysSet` represents a simultaneously pressed chord of keys. You can construct a `KeysSet` using Key's extension function:
``` kotlin
Key.CtrlLeft + Key.Enter
```
`ShortcutHandler` accepts `KeysSet` and returns a handler which could be used as a callback for `keyInputFilter`
## Event handlers
There are two different ways how you can handle key events in Compose for Desktop:
- By setting up an event handler based on a focused component
- By setting up an event handler in the scope of the window
## Focus related events
It's working in the same way as in Compose for Android, see for details [API Reference](https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/package-summary#keyinputfilter)
The most common use case is to define keyboard handlers for active controls like `TextField`. Here is an example:
Note an annotation `@OptIn(ExperimentalKeyInput::class)`. Keyboard-related event handlers are a still-experimental feature of Compose and API changes are possible, so it requires it to use special annotation to emphasize the experimental nature of the code.
![keyInputFilter](keyInputFilter.gif)
## Window-scoped events
`AppWindow` instances have `keyboard` property. Using it, it's possible to define keyboard shortcuts that are always active for the current window. See an example: