Rotary Encoder als scrollrad

So hier mal das script ..... hab aber irgendwo noch ein Fehler drin......
......expected '}' at end of input.........
aber den find ich auch noch

#include <Keyboard.h>
#define ENCODER_DO_NOT_USE_INTERRUPTS
#include <Encoder.h>
#include <Mouse.h>

Encoder myEnc(A0, A1);

  // Variables will change:
long previousMillis = 0;        // will store last time LED was updated
 
// Distance to scroll
long scrollDistance = 0;
int sensitivity = 1;
 
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 300;           // interval at which to blink (milliseconds)
 
// Number of buttons to handle
const int buttonsCount = 12;

// Arduino PINs to use
const int pins[buttonsCount] = {
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10,
    11
    
};

// Keys to send (order has to match the pins array)
const byte keys[buttonsCount] = {
    64,
    65,
    66,
    67,
    68,
    69,
    70,
    27,
    72,
    73,
    74,
    75
};

bool status[buttonsCount] = {HIGH};

void setup() {
    for (int i = 0; i < buttonsCount; ++i) 
        pinMode(pins[i], INPUT);
    
  Keyboard.begin();
  //Serial.begin(9600);
  //Serial.println("Basic NoInterrupts Test:");
 
  // Mouse on/off
 // pinMode(4, INPUT);
 // digitalWrite(4, HIGH);
}
long position  = -999;

void loop() {
    for (int i = 0; i < buttonsCount; ++i) {
        const int pinStatus = digitalRead(pins[i]);
        if (pinStatus != status[i]) {
            status[i] = pinStatus;
            if (pinStatus == LOW) {
                Keyboard.press(keys[i]);
            } else {
                Keyboard.release(keys[i]);
            
        
  unsigned long currentMillis = millis();
  long newPos = myEnc.read();
 
  if(currentMillis - previousMillis > interval) {
    // Last interval time
    previousMillis = currentMillis;  
   
    //Serial.println("Interval reached");
    //Serial.println(scrollDistance);
   
    scrollDistance = newPos;
   
    // Send scroll distance to computer
    scrollDistance = scrollDistance * sensitivity;
   
    // Scroll mouse if connected
    // if(digitalRead(4) == HIGH)
    {
      Mouse.begin();
      Mouse.move(0,0, scrollDistance);
    }
  } else 
      Mouse.end();
    }
        
        
    // Reset scroll position
    myEnc.write(0);
        }
        }
        //Serial.println(scrollDistance);