Triggers¶
A trigger is what makes a command fire. A command needs at least one, and it can have several. The kinds are:
- a spoken pattern (one or more),
- a key, mouse button, or device button,
- a variable condition.
Any or all¶
When a command has more than one trigger, you choose how they combine:
- Any (the default): any single trigger fires the command. Say the phrase or press the shortcut. The two are independent.
- All: every trigger must be active at once. The command fires the moment the last one becomes active.
The common use of All is hold-to-talk: hold a button while you speak. The button and the phrase both have to be active, so the command only fires when you hold and speak together.
Hold-to-talk is not push-to-talk
Hold-to-talk is a condition on one command (this button, held, plus this phrase). Push-to-talk is a broader listen gate that a whole category or profile can set. They look similar but do different jobs.
Input triggers¶
An input trigger names one or more keys or buttons and how they are read:
| Mode | Fires |
|---|---|
| On press | when the input is pressed |
| On release | when it is released |
| On double tap | on a quick second press |
| On long press | when held past a threshold |
| While held | active the whole time it is held (used with All) |
Gesture timing and confidence
On double tap and on long press use a built-in timing threshold. Set
double_tap_ms or long_press_ms on the input trigger to change it. A command
can also set a confidence value, from 0.0 to 1.0, to require a surer
recognition match before its spoken pattern fires.
Example¶
Say the phrase, or press Ctrl+M, to open the map:
[[command]]
name = "open_map"
description = "Open the galaxy map."
lua = "amri.input.tap('m')"
[command.trigger]
pattern = "[open;show] the map"
key = { keys = ["ctrl", "m"], mode = "on_press" }
That is Any: either trigger works on its own. Add require_all = true and set
the key's mode to while_held, and it becomes hold-to-talk: the command fires
only while you hold the key and speak.