esc

Keyboard shortcuts

Actions a person can run from any app with a keyboard shortcut, like muting every microphone. You name each action and a letter; the person picks the keys on your add-on's Settings page, and Ledge tells you when they're pressed. Needs LedgeKit 0.22.0.

Offering actions

Add "shortcut" to surfaces, set kit.minAPI to 0.22.0, and send the actions once the add-on is ready. Each send replaces the last; an empty list takes them away.

AddOnSession.show(shortcuts: [
    AddOnShortcut("mute", title: "Mute microphones", key: "M"),
    AddOnShortcut("louder", title: "Boost volume", key: "B"),
])

handlers.onEvent = { event in
    guard event.surface == Surface.shortcut, event.action == .pressed else { return }
    switch event.control {
    case "mute": await audio.muteMicrophones()
    case "louder": await audio.boost()
    default: break
    }
}

The keys

On your add-on's Settings page, the person turns each action on with Control-Option, Option-Command or Control-Option-Command and the letter you chose, or leaves it off. They're off until the person picks, so an add-on never takes a chord another app uses. A shortcut works only while your add-on is running.

Limits

  • Up to 4 actions, each with a unique id of up to 64 characters.
  • A title of up to 40 characters, shown beside the keys in Settings.
  • The key is one letter, A to Z.