> For the complete documentation index, see [llms.txt](https://raia-software-inc.gitbook.io/tacview-2-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://raia-software-inc.gitbook.io/tacview-2-documentation/api-reference/api-reference/input/keys.md).

# Keys

`Keys` contains the keyboard key values used by Tacview input and shortcut functions.

Keys are typically used together with `Modifiers` to describe keyboard shortcuts, or with input functions to check whether a key is currently down or was pressed during the last frame.

## Values

### Number keys

| Name         | Description |
| ------------ | ----------- |
| `Keys.Zero`  | 0 key.      |
| `Keys.One`   | 1 key.      |
| `Keys.Two`   | 2 key.      |
| `Keys.Three` | 3 key.      |
| `Keys.Four`  | 4 key.      |
| `Keys.Five`  | 5 key.      |
| `Keys.Six`   | 6 key.      |
| `Keys.Seven` | 7 key.      |
| `Keys.Eight` | 8 key.      |
| `Keys.Nine`  | 9 key.      |

### Letter keys

| Name     | Description |
| -------- | ----------- |
| `Keys.A` | A key.      |
| `Keys.B` | B key.      |
| `Keys.C` | C key.      |
| `Keys.D` | D key.      |
| `Keys.E` | E key.      |
| `Keys.F` | F key.      |
| `Keys.G` | G key.      |
| `Keys.H` | H key.      |
| `Keys.I` | I key.      |
| `Keys.J` | J key.      |
| `Keys.K` | K key.      |
| `Keys.L` | L key.      |
| `Keys.M` | M key.      |
| `Keys.N` | N key.      |
| `Keys.O` | O key.      |
| `Keys.P` | P key.      |
| `Keys.Q` | Q key.      |
| `Keys.R` | R key.      |
| `Keys.S` | S key.      |
| `Keys.T` | T key.      |
| `Keys.U` | U key.      |
| `Keys.V` | V key.      |
| `Keys.W` | W key.      |
| `Keys.X` | X key.      |
| `Keys.Y` | Y key.      |
| `Keys.Z` | Z key.      |

### Basic keys

| Name         | Description |
| ------------ | ----------- |
| `Keys.Space` | Space key.  |

### Special character keys

| Name          | Description |
| ------------- | ----------- |
| `Keys.Period` | Period key. |

### Function keys

| Name       | Description |
| ---------- | ----------- |
| `Keys.F1`  | F1 key.     |
| `Keys.F2`  | F2 key.     |
| `Keys.F3`  | F3 key.     |
| `Keys.F4`  | F4 key.     |
| `Keys.F5`  | F5 key.     |
| `Keys.F6`  | F6 key.     |
| `Keys.F7`  | F7 key.     |
| `Keys.F8`  | F8 key.     |
| `Keys.F9`  | F9 key.     |
| `Keys.F10` | F10 key.    |
| `Keys.F11` | F11 key.    |
| `Keys.F12` | F12 key.    |

### Numpad keys

| Name               | Description       |
| ------------------ | ----------------- |
| `Keys.Numpad0`     | Numpad 0 key.     |
| `Keys.Numpad1`     | Numpad 1 key.     |
| `Keys.Numpad2`     | Numpad 2 key.     |
| `Keys.Numpad3`     | Numpad 3 key.     |
| `Keys.Numpad4`     | Numpad 4 key.     |
| `Keys.Numpad5`     | Numpad 5 key.     |
| `Keys.Numpad6`     | Numpad 6 key.     |
| `Keys.Numpad7`     | Numpad 7 key.     |
| `Keys.Numpad8`     | Numpad 8 key.     |
| `Keys.Numpad9`     | Numpad 9 key.     |
| `Keys.NumpadPlus`  | Numpad plus key.  |
| `Keys.NumpadMinus` | Numpad minus key. |

### Navigation keys

| Name            | Description      |
| --------------- | ---------------- |
| `Keys.Up`       | Up arrow key.    |
| `Keys.Down`     | Down arrow key.  |
| `Keys.Left`     | Left arrow key.  |
| `Keys.Right`    | Right arrow key. |
| `Keys.PageUp`   | Page Up key.     |
| `Keys.PageDown` | Page Down key.   |
| `Keys.Home`     | Home key.        |
| `Keys.End`      | End key.         |

## Remarks

The list of available keys may grow over time as Tacview exposes more keyboard input values.

Use `Keys` values with `Modifiers` when defining or checking shortcuts.

For standard user-interface shortcuts, prefer `Modifiers.Primary` instead of hard-coding `Modifiers.Control`. This lets Tacview use Control on Windows and Linux, and Command on macOS.

## Example

This example triggers an **Open File** command when the user presses the standard platform shortcut for opening files.

```lua
if WasShortcutPressed(0, Modifiers.Primary, Keys.O) then

	RequestFilesToLoad()

end
```

This is preferable to hard-coding Control+O, because `Modifiers.Primary` follows the user's operating system conventions.

## Example with a menu item

```lua
local LoadFilesId = "LoadFiles"

AddMenuItem(mainMenuHandle, {
	path = "File",
	group = "Open",
	id = LoadFilesId,
	label = "Open File...",
	shortcut = {
		modifiers = Modifiers.Primary,
		key = Keys.O
	}
})
```

The shortcut displayed next to the menu item uses the appropriate platform convention.

## Related functions

Keys are useful with input functions such as:

* `IsKeyDown()`
* `WasKeyPressed()`
* `GetKeyPressCount()`
* `WasShortcutPressed()`

## See also

* `Modifiers`
* `AddMenuItem()`
* `WasShortcutPressed()`
* `IsKeyDown()`
* `WasKeyPressed()`
* `GetKeyPressCount()`
