two leds with two buttons

button1 light redled for 2000ms (one press)
button2 light blueled for 2000ms (one press)
the problem is when both are pressed in the same time , there is an allowed time for the second press to occur which is 50ms my following code doesnt seem to give any 1ms chance for the second press to happen , my target is (within 50ms of the first press if button2 is pressed both leds should light up together for 2000ms)

int redled=3;
int blueled=4;
int button1=6;
int button2=5;

void setup () {
pinMode(redled,OUTPUT);
pinMode(blueled,OUTPUT);
pinMode(button1,INPUT);
pinMode(button2,INPUT);
}

void loop () {
int buttonstate = digitalRead(button1);
if (buttonstate == 1) {
digitalWrite(redled,HIGH);
delay(2000);
digitalWrite(redled,LOW);
}
int buttonstate2 = digitalRead(button2);
if (buttonstate2 == 1) {
digitalWrite(blueled,HIGH);
delay(2000);
digitalWrite(blueled,LOW);
}
int buttonstate3 = digitalRead(button1) + digitalRead(button2);
if (buttonstate3 == 2) {
digitalWrite(redled,HIGH);
digitalWrite(blueled,HIGH);
delay(2000);
digitalWrite(redled,LOW);
digitalWrite(blueled,LOW);
}
}

If you are going to determine that two switches have been pressed within some interval, you need to record when each press happens. You need to study the state change detection example to see how to determine that a switch has BECOME pressed, rather than checking that a switch IS pressed.

And, of course, your code will contain NO calls to delay. See the blink without delay example.

after studying "the state change detection" i still dont know how to store the the time each button has been pressed in , to compare it with 50ms

hossamsh:
after studying "the state change detection" i still dont know how to store the the time each button has been pressed in , to compare it with 50ms

Store the value of millis() in an unsigned long variable when you detect the button press.