Module

# Keyboard

<div class="rst-class">

forsearch

</div>

Keyboard

<div class="rst-class">

forsearch

</div>

Hardware

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

An intrinsic object that represents the current state of the <span class="title-ref">Keyboard</span>. A convenient place to test for <span class="title-ref">Keyboard</span> events is the Action event of a `Timer</api/language/timer>`.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                                    | Type                               | Read-Only | Shared |
|-------------------------------------------------------------------------|------------------------------------|-----------|--------|
| `AlternateMenuShortCutKey<keyboard.alternatemenushortcutkey>`           | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AltKey<keyboard.altkey>`                                               | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AsyncAlternateMenuShortCutKey<keyboard.asyncalternatemenushortcutkey>` | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AsyncAltKey<keyboard.asyncaltkey>`                                     | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AsyncCommandKey<keyboard.asynccommandkey>`                             | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AsyncControlKey<keyboard.asynccontrolkey>`                             | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AsyncMenuShortcutKey<keyboard.asyncmenushortcutkey>`                   | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AsyncOptionKey<keyboard.asyncoptionkey>`                               | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AsyncOSKey<keyboard.asyncoskey>`                                       | `Boolean</api/data_types/boolean>` | ✓         |        |
| `AsyncShiftKey<keyboard.asyncshiftkey>`                                 | `Boolean</api/data_types/boolean>` | ✓         |        |
| `CommandKey<keyboard.commandkey>`                                       | `Boolean</api/data_types/boolean>` | ✓         |        |
| `ControlKey<keyboard.controlkey>`                                       | `Boolean</api/data_types/boolean>` | ✓         |        |
| `MenuShortcutKey<keyboard.menushortcutkey>`                             | `Boolean</api/data_types/boolean>` | ✓         |        |
| `OptionKey<keyboard.optionkey>`                                         | `Boolean</api/data_types/boolean>` | ✓         |        |
| `OSKey<keyboard.oskey>`                                                 | `Boolean</api/data_types/boolean>` | ✓         |        |
| `ShiftKey<keyboard.shiftkey>`                                           | `Boolean</api/data_types/boolean>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                  | Parameters                                    | Returns                            | Shared |
|---------------------------------------|-----------------------------------------------|------------------------------------|--------|
| `AsyncKeyDown<keyboard.asynckeydown>` | keyCode As `Integer</api/data_types/integer>` | `Boolean</api/data_types/boolean>` |        |
| `Keyname<keyboard.keyname>`           | keyCode As `Integer</api/data_types/integer>` | `String</api/data_types/string>`   |        |

## Property descriptions

<div id="keyboard.alternatemenushortcutkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AlternateMenuShortCutKey

**AlternateMenuShortCutKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the alternate menu shortcut modifier is depressed when the current method or event handler began. This checks the Shift key on all platforms.
>
> This property is read-only.
>
> This example detects the Shift key. It is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.AlternateMenuShortcutKey Then
>   ' handle the keyboard event here....
> End If
> ```

<div id="keyboard.altkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AltKey

**AltKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Alt key on Windows and Linux and Option key on macOS was depressed when the current method or event handler began.
>
> This property is read-only.
>
> This example detects the Alt or Option key. It is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.AltKey Then
>   MessageBox("Option/Alt key")
> End If
> ```

<div id="keyboard.asyncalternatemenushortcutkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncAlternateMenuShortCutKey

**AsyncAlternateMenuShortCutKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the alternate menu shortcut key is depressed. This checks the Shift key on all platforms.
>
> This property is read-only.
>
> The following example detects the Shift key. The code is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.AsyncAlternateMenuShortcutKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.asyncaltkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncAltKey

**AsyncAltKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Alt key (Windows and Linux) or Option key (MacOS) is depressed.
>
> This property is read-only.
>
> This example detects whether the Alt/Option key is depressed.
>
> ``` xojo
> If Keyboard.AsyncAltKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.asynccommandkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncCommandKey

**AsyncCommandKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Command key is depressed on macOS (or Windows/OS key on Windows/Linux).
>
> This property is read-only.
>
> ``` xojo
> If Keyboard.AsyncCommandKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.asynccontrolkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncControlKey

**AsyncControlKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Control key is depressed.
>
> This property is read-only.
>
> This example detects whether the Control key is depressed.
>
> ``` xojo
> If Keyboard.AsyncControlKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.asyncmenushortcutkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncMenuShortcutKey

**AsyncMenuShortcutKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the menu shortcut modifier key is depressed. This property tests the Control key on Windows and Linux and the Command key on macOS.
>
> This property is read-only.
>
> The following example detects the menu modifier on the user's platform.
>
> ``` xojo
> If Keyboard.AsyncMenuShortcutKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.asyncoptionkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncOptionKey

**AsyncOptionKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Option key (macOS) or Alt key (Windows and Linux) is depressed.
>
> This property is read-only.
>
> The following code detects whether the Option key on macOS was depressed.
>
> ``` xojo
> If Keyboard.AsyncOptionKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.asyncoskey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncOSKey

**AsyncOSKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the OS key is depressed. On Windows and Linux, this is the key with the Windows flag; on macOS, it is the Command key.
>
> This property is read-only.
>
> This example detects whether the OS key was depressed. It is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.AsyncOSKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.asyncshiftkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncShiftKey

**AsyncShiftKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Shift key is depressed.
>
> This property is read-only.
>
> This example detects the Shift key. The code is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.AsyncShiftKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.commandkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.CommandKey

**CommandKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Command key is depressed on macOS (or Windows/OS key on Windows/Linux) when the current method or event handler began.
>
> This property is read-only.
>
> The following code detects whether the Command key is depressed. The code is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.CommandKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.controlkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.ControlKey

**ControlKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Control key was depressed when the current method or event handler began.
>
> This property is read-only.
>
> This example detects whether the Control key is depressed. The code is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.ControlKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.menushortcutkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.MenuShortcutKey

**MenuShortcutKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the menu shortcut modifier key was depressed when the current method or event handler began. This property tests the Control key on Windows and Linux and the Command key on macOS.
>
> This property is read-only.
>
> This example detects whether the menu shortcut modifier key was depressed. The code is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.MenuShortcutKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.optionkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.OptionKey

**OptionKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Alt key (Windows and Linux) or Option key (MacOS) is depressed when the method/event began.
>
> This property is read-only.
>
> This code detects whether the Option key was depressed. The code is in the Action event of a `Timer</api/language/timer>`:
>
> ``` xojo
> If Keyboard.OptionKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.oskey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.OSKey

**OSKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the OS key was depressed when the current method or event handler began. On Windows and Linux, this is the Windows flag key; on macOS, it is the Command key.
>
> This property is read-only.
>
> This example detects whether the OS key was depressed on the user's platform. The code is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.OSKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

<div id="keyboard.shiftkey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.ShiftKey

**ShiftKey** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Shift key was depressed when the current method or event handler began.
>
> This property is read-only.
>
> This example detects whether the Shift key was depressed. The code is in the Action event of a `Timer</api/language/timer>`.
>
> ``` xojo
> If Keyboard.ShiftKey Then
>   ' handle the keyboard event here....
>   MessageBox("keyboard event detected...")
> End If
> ```

## Method descriptions

<div id="keyboard.asynckeydown">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.AsyncKeyDown

**AsyncKeyDown**(keyCode As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the key whose *KeyCode* was passed is depressed. See the tables in the <span class="title-ref">Keyboard</span> Notes section for the values of *KeyCode* for the English (American) <span class="title-ref">Keyboard</span>.
>
> The following example monitors the arrow keys and detects whether one of them is depressed. The code is in the Action event of a `Timer</api/language/timer>` control.
>
> ``` xojo
> If Keyboard.AsyncKeyDown(&h7B) Then
>   ' do something with the left arrow key
> End If
> If Keyboard.AsyncKeyDown(&h7C) Then
>   ' do something with the right arrow key...
> End If
> If Keyboard.AsyncKeyDown(&h7D) Then
>   ' do something with the down arrow key...
> End If
> If Keyboard.AsyncKeyDown(&h7E) Then
>   ' do something with the Up arrow key...
> End If
> ```
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On Linux distros and desktop environments defaulting to Wayland, AsyncKeyDown will likely not fire due to Wayland's tighter security protocols, specifically regarding global <span class="title-ref">keyboard</span> shortcuts. Instead, use the KeyDown event of the window/control you want to receive input from.
>
> </div>

<div id="keyboard.keyname">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Keyboard.Keyname

**Keyname**(keycode As `Integer</api/data_types/integer>`) As `String</api/data_types/string>`

> Returns as a `String</api/data_types/string>` the name of the keycode passed.
>
> Refer to the <span class="title-ref">Keyboard</span> Notes to a list of key codes.
>
> This returns a value that indicates the character the key produces. In most cases, special keys will be named as follows: `Esc`, `Tab`, `CapsLock`, `Shift`, `Control`, `Option`, `Alt`, `Command`, `Win`, `Return`, `Enter`, `Space`, `Fn`, `Delete`, `Backspace`, `Help`, `Insert`, `Home`, `PageUp`, `Del`, `End`, `PageDown`, `F1` through `F15`, `PrintScreen`, `ScrollLock`, `Pause`/`Break`, `Clear`, `NumLock`, `KP=`, `KP/`, `KP*`, `KP-`, `KP0` through `KP9`, `Up`, `Left`, `Down` and `Right`.
>
> The following example returns the name of character &h7D. It is the Down arrow key.
>
> ``` xoj
> MessageBox(Keyboard.keyname(&h7D))
> ```

## Notes

The <span class="title-ref">Keyboard</span> module is used to determine if particular keys are being pressed. The async version of each <span class="title-ref">Keyboard</span> property tells you the immediate state of the key. If you want to know the state of the key when an event was queued, you should use the non-async version of the properties. These properties are updated constantly during code execution.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Windows

You can pass raw Win32 key codes to AsyncKeyDown. Add 1 to the raw keyCode and put it in the high word of the `Integer</api/data_types/integer>` you are passing. For example:

``` xojo
Keyboard.AsyncKeyDown((rawKeyCode + 1) * &hFFFF)
```

The "regular" way of detecting a particular keyCode, illustrated by the first example in the Examples section, also works for Windows.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Keycodes

The following tables give the keycodes for the US <span class="title-ref">Keyboard</span>. Keyboards for other languages may differ. These values are given in hex. You can pass values in another base if you wish. See the Examples section for examples that use Decimal and Hex values.

The AsyncKeyDown property returns `True</api/language/true>` when the keycode passed to it is pressed.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Letters of the alphabet

| Key | KeyCode (hex value) |
|-----|---------------------|
| a   | 00                  |
| b   | 0B                  |
| c   | 08                  |
| d   | 02                  |
| e   | 0E                  |
| f   | 03                  |
| g   | 05                  |
| h   | 04                  |
| i   | 22                  |
| j   | 26                  |
| k   | 28                  |
| l   | 25                  |
| m   | 2E                  |
| n   | 2D                  |
| o   | 1F                  |
| p   | 23                  |
| q   | 0C                  |
| r   | 0F                  |
| s   | 01                  |
| t   | 11                  |
| u   | 20                  |
| v   | 09                  |
| w   | 0D                  |
| x   | 07                  |
| y   | 10                  |
| z   | 06                  |

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Numbers

| Key | KeyCode (hex value) |
|-----|---------------------|
| 0   | 1D                  |
| 1   | 12                  |
| 2   | 13                  |
| 3   | 14                  |
| 4   | 15                  |
| 5   | 17                  |
| 6   | 16                  |
| 7   | 1A                  |
| 8   | 1C                  |
| 9   | 19                  |

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Function and special keys

| Key       | KeyCode (hex value) |
|-----------|---------------------|
| F1        | 7A                  |
| F2        | 78                  |
| F3        | 63                  |
| F4        | 76                  |
| F5        | 60                  |
| F6        | 61                  |
| F7        | 62                  |
| F8        | 64                  |
| F9        | 65                  |
| F10       | 6D                  |
| F11       | 67                  |
| F12       | 6F                  |
| F13       | 69                  |
| F14       | 6B                  |
| F15       | 71                  |
| ESC       | 35                  |
| Space     | 31                  |
| Tab       | 30                  |
| Return    | 24                  |
| Home      | 73                  |
| Backspace | 33                  |
| End       | 77                  |
| Page Up   | 74                  |
| Page Down | 79                  |
| Delete    | 75                  |
| Help      | 72                  |
| Left      | 7B                  |
| Right     | 7C                  |
| Up        | 7E                  |
| Down      | 7D                  |
| =         | 18                  |
| –         | 1B                  |
| \[        | 21                  |
| \]        | 1E                  |
| \\        | 2A                  |
| '         | 32                  |
| '         | 27                  |
| ;         | 29                  |
| /         | 2C                  |
| ,         | 2B                  |
| .         | 2F                  |
| ,         | 2B                  |

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Numeric keypad codes

| Key   | KeyCode (hex value) |
|-------|---------------------|
| 1     | 53                  |
| 2     | 54                  |
| 3     | 55                  |
| 4     | 56                  |
| 5     | 57                  |
| 6     | 58                  |
| 7     | 59                  |
| 8     | 5B                  |
| 9     | 5C                  |
| 0     | 52                  |
| \+    | 45                  |
| –     | 4E                  |
| /     | 4B                  |
| \*    | 43                  |
| Enter | 4C                  |
| .     | 41                  |
| Clear | 47                  |

## Sample code

The following code tests whether the key for the letter "A" was pressed:

``` xojo
If Keyboard.AsynckeyDown(&h00) Then
' do something with this key here
End If
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code monitors the arrow keys and detects when an arrow key is pressed. Base 10 values are passed. Place this code in the Action event of a `Timer</api/language/timer>` and it will monitor the <span class="title-ref">Keyboard</span> continuously.

``` xojo
If Keyboard.AsyncKeyDown(123) Then
  ' do something with the left arrow key
End If
If Keyboard.AsyncKeyDown(124) Then
  ' do something with the right arrow key...
End If
If Keyboard.AsyncKeyDown(125) Then
  ' do something with the down arrow key...
End If
If Keyboard.AsyncKeyDown(126) Then
  ' do something with the Up arrow key...
End If
```

## Compatibility

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

`DesktopUIControl.KeyDown<desktopuicontrol.keydown>`, `DesktopUIControl.KeyUp<desktopuicontrol.keyup>` events

</div>
