Digispark click code help

See the File->Examples->02.Digital->StateChangeDetection example. It shows how to use a global variable to keep track of the previous state of the button. That way you can tell when the button state changes.

You will end up with something like:

#include <DigiMouse.h>

const byte ButtonPin = 2;
bool ButtonWasPressed = false;     // previous state of the button

void setup()
{
  DigiMouse.begin();
  pinMode(ButtonPin, INPUT_PULLUP);
}

void loop()
{
  bool buttonIsPressed = digitalRead(ButtonPin) == LOW;

  if (buttinIsPressed != ButtonWasPressed)
  {
    // Button state has changed
    ButtonWasPressed = buttonIsPressed;

    if (buttonIsPressed)
      DigiMouse.setButtons(1 << 0);  // Click button 0
    else
      DigiMouse.setButtons(0); //unclick all
  }
}