PowerKeys Scripting API
    Preparing search index...

    Interface HotstringAPI

    interface HotstringAPI {
        Register(trigger: string, replacement: string | EventCallback<[]>): void;
        Unregister(trigger: string): void;
    }
    Index
    • Registers a hotstring trigger. When the user types the trigger text, it is automatically erased and replaced with the replacement text, or the callback function is invoked.

      Parameters

      • trigger: string

        The text sequence that activates the hotstring (e.g. "btw").

      • replacement: string | EventCallback<[]>

        Either a replacement string (e.g. "by the way") or a callback function that runs custom logic when the trigger is typed.

      Returns void

      AHK equivalent: ::btw::by the way. The trigger is erased by sending backspace keystrokes equal to its length, then the replacement is typed. Use the callback form for replacements that require scripted logic (e.g. inserting the current date).

      // String replacement
      Hotstring.Register("btw", "by the way");

      // Callback for dynamic replacement
      Hotstring.Register("ddate", async () => {
      await Keyboard.Type(new Date().toLocaleDateString());
      });

      keyboard

    • Removes a previously registered hotstring so it no longer triggers.

      Parameters

      • trigger: string

        The same trigger string that was passed to Hotstring.Register().

      Returns void

      Hotstring.Unregister("btw");
      

      keyboard