Search documentation of Plushie

# Plushie.Protocol.Keys (Plushie v0.7.2)

Copy Markdown View Source

Named keyboard key mappings and validation.

Maps wire-format key name strings (PascalCase, matching iced's `keyboard::key::Named` debug format) to Elixir atoms. Used by the protocol decoder to convert key events and by test helpers to validate key names at call time.

## Summary

### Functions

parse_key(key)

Converts a key name string to an atom for named keys, or returns the string unchanged for single-character keys.

parse_location(arg1)

Parses a key location string to an atom.

parse_physical_key(str)

Converts a physical key code string to an atom, or returns the string unchanged for unknown codes.

## Functions

# parse_key(key)

    @spec parse_key(key :: String.t()) :: atom() | String.t()

Converts a key name string to an atom for named keys, or returns the string unchanged for single-character keys.

## Examples

    iex> Plushie.Protocol.Keys.parse_key("Escape")
    :escape

    iex> Plushie.Protocol.Keys.parse_key("a")
    "a"

# parse_location(arg1)

    @spec parse_location(String.t() | nil) :: :left | :right | :numpad | :standard

Parses a key location string to an atom.

# parse_physical_key(str)

    @spec parse_physical_key(term()) :: atom() | String.t() | nil

Converts a physical key code string to an atom, or returns the string unchanged for unknown codes.