Nested leader key
To nest leader keys, use a variables:
- Set the variable on the leader key (Default value 1; 0 when unset)
 - Set the variable to different value on each nested leader key (other than 1 or 0)
 - Unset the variable on all action keys and escape key(s)
 - (optional) Use notification for hints
 
Example code: ( Open in the online editor → )
let raycastEmoji = 'raycast/emoji-symbols/search-emoji-symbols'
let escape = [toUnsetVar('leader'), toRemoveNotificationMessage('leader')]
let rules = [
  rule('Leader Key').manipulators([
    // When no leader key or nested leader key is on
    withCondition(ifVar('leader', 0))([
      // Leader key
      map('l', 'Hyper') // Or mapSimultaneous(['l', ';']) ...
        .toVar('leader', 1)
        .toNotificationMessage('leader', 'Leader Key: Open, Raycast, ...'),
    ]),
    // When leader key or nested leader key is on
    withCondition(ifVar('leader', 0).unless())([
      // Escape key(s)
      map('escape').to(escape),
    ]),
    // When leader key but no nested leader key is on
    withCondition(ifVar('leader', 1))([
      // Nested leader keys
      withMapper(['o', 'r'])((x) =>
        map(x)
          .toVar('leader', x)
          .toNotificationMessage('leader', `leader ${x}`),
      ),
    ]),
    // leader o - Open
    withCondition(ifVar('leader', 'o'))(
      [
        map('f').toApp('Finder'),
        // f - Finder, ...
      ].map((x) => x.to(escape)),
    ),
    // leader r - Raycast
    withCondition(ifVar('leader', 'r'))(
      [
        map('e').to$(`open raycast://extensions/${raycastEmoji}`),
        // e - Emoji, ...
      ].map((x) => x.to(escape)),
    ),
  ]),
]