Plushie.KeyModifiers (Plushie v0.6.0)

Copy Markdown View Source

Keyboard modifier state at the time of a key event.

Each field is a boolean indicating whether that modifier was held.

Fields

  • ctrl -- Control key (Ctrl on Windows/Linux).
  • shift -- Shift key.
  • alt -- Alt key (Option on macOS).
  • logo -- Logo/Super key (Windows key, Command symbol on macOS).
  • command -- Platform command key (Ctrl on Windows/Linux, Cmd on macOS).

Example

%Plushie.KeyModifiers{ctrl: true, shift: false, alt: false, logo: false, command: true}

Use the query functions for readable conditional logic:

if KeyModifiers.ctrl?(event.modifiers) do
  handle_shortcut(event)
end

Summary

Functions

Returns true if the Alt modifier is active.

Returns true if the platform Command modifier is active.

Returns true if the Ctrl modifier is active.

Returns true if the Logo/Super modifier is active.

Returns true if the Shift modifier is active.

Types

t()

@type t() :: %Plushie.KeyModifiers{
  alt: boolean(),
  command: boolean(),
  ctrl: boolean(),
  logo: boolean(),
  shift: boolean()
}

Functions

alt?(key_modifiers)

@spec alt?(modifiers :: t()) :: boolean()

Returns true if the Alt modifier is active.

command?(key_modifiers)

@spec command?(modifiers :: t()) :: boolean()

Returns true if the platform Command modifier is active.

ctrl?(key_modifiers)

@spec ctrl?(modifiers :: t()) :: boolean()

Returns true if the Ctrl modifier is active.

logo?(key_modifiers)

@spec logo?(modifiers :: t()) :: boolean()

Returns true if the Logo/Super modifier is active.

shift?(key_modifiers)

@spec shift?(modifiers :: t()) :: boolean()

Returns true if the Shift modifier is active.