LavaUI docs GitHub

struct KeyShortcut

Swift

struct KeyShortcut

Keyboard shortcut attached to a menu item.

Use KeyShortcut(KeyCode.s, .primary) for the platform save chord. Matching against live key events uses matches(key:mods:) with the same GLFW numbering as InputEvent.

Sources/LavaMenu/Menu.swift:91

Constructors

init(_ key: Int32, _ modifiers: KeyShortcutModifier = [])

Creates a shortcut from a key and a set of modifiers.

Sources/LavaMenu/Menu.swift:98

init(_ key: Int32, _ modifiers: KeyShortcutModifier...)

Creates a shortcut from a key and any number of modifiers: KeyShortcut(KeyCode.s, .primary, .shift).

Sources/LavaMenu/Menu.swift:104

Properties

var key: Int32

The key, as a GLFW / LavaUI KeyCode.

Sources/LavaMenu/Menu.swift:93

var modifiers: KeyShortcutModifier

The modifiers held with it.

Sources/LavaMenu/Menu.swift:95

static var platformPrimaryMod: Int32 { get }

Platform primary modifier bit (Super/Cmd on macOS, Control elsewhere). Values match GLFW / LavaUI KeyMods.

Sources/LavaMenu/Menu.swift:113

Methods

func matches(key: Int32, mods: Int32, primary: Int32 = KeyShortcut.platformPrimaryMod) -> Bool

Whether a physical key event matches this shortcut exactly on the mod bits.

Sources/LavaMenu/Menu.swift:133

func resolvedMods(primary: Int32 = KeyShortcut.platformPrimaryMod) -> Int32

GLFW-style mod bitfield for this shortcut.

Sources/LavaMenu/Menu.swift:122