Lighting LED using keypad and microcontroller
The equality testing operator is ==, the assignment operator is =.

You are using = instead of == so the if condition returns always true.

This line if(keypressed == '1') assigns character 1 to the keypressed variable, since  keypressed becomes a non zero value the if condition is always true.

The code should be like:

if(keypressed == '1')
{
    digitalWrite(led1, HIGH);
    delay(500);
    digitalWrite(led1, LOW);
    delay(500);
}

if(keypressed == '2')
{

    digitalWrite(led2, HIGH);
    delay(500);
    digitalWrite(led2, LOW);
    delay(500);

}