# `ExRatatui.Event.Key`
[🔗](https://github.com/mcass19/ex_ratatui/blob/v0.7.1/lib/ex_ratatui/event/key.ex#L1)

A keyboard event.

## Fields

  * `:code` - the key that was pressed, as a string (see Key Codes below)
  * `:kind` - `"press"`, `"release"`, or `"repeat"`
  * `:modifiers` - list of active modifiers: `"shift"`, `"ctrl"`, `"alt"`,
    `"super"`, `"hyper"`, `"meta"`

## Key Codes

Character keys are returned as their string value (`"a"`, `"z"`, `"1"`, `" "`, etc.).

Special keys:

| Code | Key |
|------|-----|
| `"enter"` | Enter / Return |
| `"esc"` | Escape |
| `"tab"` | Tab |
| `"back_tab"` | Shift+Tab |
| `"backspace"` | Backspace |
| `"delete"` | Delete |
| `"insert"` | Insert |
| `"up"` | Arrow Up |
| `"down"` | Arrow Down |
| `"left"` | Arrow Left |
| `"right"` | Arrow Right |
| `"home"` | Home |
| `"end"` | End |
| `"page_up"` | Page Up |
| `"page_down"` | Page Down |
| `"f1"` .. `"f12"` | Function keys |
| `"caps_lock"` | Caps Lock |
| `"scroll_lock"` | Scroll Lock |
| `"num_lock"` | Num Lock |
| `"print_screen"` | Print Screen |
| `"pause"` | Pause |
| `"menu"` | Menu / Context |
| `"keypad_begin"` | Keypad Begin (numpad 5) |

## Examples

    iex> %ExRatatui.Event.Key{code: "q", kind: "press"}
    %ExRatatui.Event.Key{code: "q", kind: "press", modifiers: []}

    iex> %ExRatatui.Event.Key{code: "c", kind: "press", modifiers: ["ctrl"]}
    %ExRatatui.Event.Key{code: "c", kind: "press", modifiers: ["ctrl"]}

Pattern matching on events:

    # Match any arrow key
    %Event.Key{code: code, kind: "press"} when code in ~w(up down left right)

# `t`

```elixir
@type t() :: %ExRatatui.Event.Key{
  code: String.t() | nil,
  kind: String.t() | nil,
  modifiers: [String.t()]
}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
