---
// cSpell: ignore Backtab
title: Key Handling Overview
description: Key Handling Overview
---

import Link from '@slint/common-files/src/components/Link.astro';
import SpecialKeys from "../../../collections/enums/keys.md"

To handle keyboard input in Slint, use the `FocusScope` or individual `key-pressed` and `key-released` callbacks in various elements. Keyboard
input is delivered via [`KeyEvent`](#keyevent) data structures. The primary field of this data structure is the `text` property, which holds all affected keys
encoded in a string. Use the [`Key` namespace](#key-namespace) to identify known named keys.

## KeyEvent

 This structure is generated and passed to the key press and release callbacks of the `FocusScope` element.

- **`text`** (_string_):  The unicode representation of the key pressed.
- **`modifiers`** (_KeyboardModifiers_):  The keyboard modifiers active at the time of the key press event.
- **`repeat`** (_bool_):  This field is set to true for key press events that are repeated, i.e. the key is held down. It's always false for key release events.


## Key Namespace
Use the constants in the `Key` namespace to handle pressing of keys that don't have a printable character.

<SpecialKeys />
