Skip to main content

Sequences

Sequences

Sequences can be used to support gmail like actions where you click "g" then "a", or "g" then "o" to perform certain actions.

Important note

The library can get very confused if you have a single key handler that uses the same key that a sequence starts with. This is because it can't tell if you are starting the sequence or if you are pressing that key on its own.

To counter this, there is a 500ms delay(only when single key is used in the beginning of another sequence, so it won't affect performance) . This gives the library time to wait for a more complete sequence, otherwise the single sequence will be triggered.

for example: binding both "? a" and "?", then clicking "?" will trigger the "?" callback, but only after 500ms delay. However, in all other cases there's no delay in execution of the callback (unless debounceTime is provided)

Examples:

This library supports gmail style sequences:

   [{
key: ["g a"],
command: (output: ShortcutEventOutput) => console.log("? a", output),
}]

konami code:

    [{
key: ["up up down down left right left right b a enter"],
label: "Sequences",
description: "Konami code!",
command: (output: ShortcutEventOutput) => console.log("Konami code!!!", output),
}]

Sequences can be used inside components or directives and are declared without the plus(+) sign, for example: key: ["a b c"] will require clicking, a, then b, then c.