button pressed more than 2 seconds do somethingelse

you can use the below code. it works for me. I put two time cycle. press less than 10 second then system will print short press, more than 10 second then system will print Long press and not press that system will print release.
const byte keyPin = 2; // The switch is connected to pin number 2
int pressTime = 0; // the counter that acounnt the pressing time
void setup() {
Serial.begin(115200);
pinMode(keyPin, INPUT);
}
void loop() {
byte key = digitalRead(keyPin);
if (key == HIGH) { // that means the key is pressed
pressTime++;
delay(1000); // works like a timer with one second steps
if (pressTime <= 10){
Serial.println("Short click");
}else {
Serial.println("Long click");
}
}
else if (key == LOW) {// key is not pressed
Serial.println("Released");
pressTime=0;
}
Serial.println(pressTime);
}