# `Kuroneko.Gadget.HID.Keymap`
[🔗](https://github.com/cocoa-xu/kuroneko_gadget/blob/v0.5.0/lib/kuroneko/gadget/hid/keymap.ex#L1)

Key names to USB HID keyboard usages.

Keys are named by their physical position, as the W3C UI Events
`KeyboardEvent.code` values that browsers send ("KeyA", "Digit1",
"ShiftLeft", "ArrowUp"): the target computer applies its own layout.
The keyboard has the usages 0x04..0xDD and eight modifier keys.

# `code`

```elixir
@type code() :: String.t()
```

A `KeyboardEvent.code` value.

# `modifier_bit`

```elixir
@type modifier_bit() :: 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128
```

A modifier key as a bit of the boot keyboard report.

# `character`

```elixir
@spec character(char()) :: {code(), boolean()} | nil
```

The key that types a character on a US keyboard, and whether with shift;
`nil` for characters it has no key for.

    iex> Kuroneko.Gadget.HID.Keymap.character(?A)
    {"KeyA", true}
    iex> Kuroneko.Gadget.HID.Keymap.character(10)
    {"Enter", false}
    iex> Kuroneko.Gadget.HID.Keymap.character(?é)
    nil

# `modifier`

```elixir
@spec modifier(code()) :: modifier_bit() | nil
```

The report bit of a modifier key, `nil` for other keys.

    iex> Kuroneko.Gadget.HID.Keymap.modifier("ShiftLeft")
    0x02
    iex> Kuroneko.Gadget.HID.Keymap.modifier("KeyA")
    nil

# `usage`

```elixir
@spec usage(code()) :: 4..221 | nil
```

The HID usage of any other key, `nil` when the keyboard has none.

    iex> Kuroneko.Gadget.HID.Keymap.usage("KeyA")
    0x04
    iex> Kuroneko.Gadget.HID.Keymap.usage("Enter")
    0x28

---

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