PowerKeys Scripting API
    Preparing search index...

    Interface TimeAPI

    interface TimeAPI {
        Sleep(ms: number): Promise<void>;
    }
    Index
    • Asynchronously pauses the current task for the specified duration.

      Parameters

      • ms: number

        Non-negative delay duration.

      Returns Promise<void>

      A promise that resolves after the delay.

      Use await Time.Sleep(ms) inside an async hotkey callback when other hotkey presses must remain responsive while waiting. This function yields to the host, so a second press can run a start/stop toggle callback. If the script is stopped or cancelled first, the promise rejects with Error: Script cancelled.

      Hotkey.Register("F9", async () => {
      Console.Log("waiting without blocking other hotkeys");
      await Time.Sleep(500);
      });