# `keyboard`

The keyboard's lock keys, layouts and modifiers. While a Strand
surface has keyboard focus (a lock screen, a launcher, a window
switcher) they are that keyboard's own, exact as keys are pressed;
otherwise the lock keys come from the kernel's keyboard lights, read
while a visible reader shows them, the layouts from the compositor
(Hyprland, sway, niri), and no modifier is held.

| Field | Type | |
| --- | --- | --- |
| `caps_lock` | `bool` | Caps Lock is on: `if keyboard.caps_lock { text "Caps Lock is on" }`. False when nothing reports it. |
| `num_lock` | `bool` | Num Lock is on. |
| `layout` | `text?` | The active layout's name as the keymap names it (`English (US)`), null when unknown: `text keyboard.layout ?? ""`. |
| `layouts` | `[text]` | The layouts it switches between, by index, as the keymap names them (`["English (US)", "German"]`; empty when unknown): `keyboard.set_layout(i)` takes an index into it. |
| `alt` | `bool` | Alt is held, while a Strand surface has keyboard focus (false otherwise: no compositor tells): an alt-tab switcher commits when it turns false. |
| `ctrl` | `bool` | Control is held, while a Strand surface has keyboard focus. |
| `shift` | `bool` | Shift is held, while a Strand surface has keyboard focus. |
| `logo` | `bool` | The logo (Super) key is held, while a Strand surface has keyboard focus. |

| Method | |
| --- | --- |
| `action next_layout()` | Switches every keyboard to its next layout (Hyprland, sway, niri). |
| `action set_layout(index: int)` | `keyboard.set_layout(i)` switches every keyboard to layout `i` of `layouts`. |
