PowerKeys Scripting API
    Preparing search index...

    Interface HIDAPI

    interface HIDAPI {
        OnRawEvent(callback: EventCallback<[event: HidEvent]>): void;
        GetDevices(): HidDeviceInfo[];
    }
    Index
    • Registers a callback that fires on every raw HID report from vendor-defined devices. Only events from usage pages ≥ 0xFF00 are delivered. The script enters an event loop and stays alive as long as this handler is registered.

      Parameters

      Returns void

      USE CASE: Macro pads, foot pedals, and custom HID controllers that send vendor-defined reports. Standard keyboard (usage page 0x01) and mouse events are NOT delivered here. Use Keyboard.OnRawEvent or Mouse.OnRawEvent.

      HID.OnRawEvent((e) => {
      // usage_page >= 0xFF00 guaranteed
      Console.Log(e.device_name + ": " + e.raw_hex);
      if (e.raw_data[0] === 0x01) {
      Console.Log("button 1 pressed");
      }
      });

      hid

    • Returns a list of all enumerated HID devices currently registered for raw input.

      Returns HidDeviceInfo[]

      A snapshot of the currently registered raw-input HID devices; the array is empty when none are registered.

      const devices = HID.GetDevices();
      devices.forEach((d) => {
      Console.Log(d.product_name + " (page: 0x" + d.usage_page.toString(16) + ")");
      });

      hid