What am I doing srong?

I'm new to Arduino and this is my first project I'm (kind of) doing on my own but I can't figure out what I'm doing wrong with the code. What I am trying to do is a motion detector alarm which I can turn off during 60 seconds with a passcode but I'm getting the error message "keypadEvent was not declared in this scope", what am I doing wrong? If there is anything else wrong with my code please tell me.

#include <Password.h>

#include <Keypad.h>



float sinVal;
int toneVal;
int brightness;
boolean alarmState;
Password password = Password( "4155" );
const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] ={
  {
    '1', '2', '3', 'A', }
  ,
  { 
     '4', '5', '6', 'B', }
  ,
  {
     '7', '8', '9', 'C', }
  ,
  {
     '*', '0', '#', 'D', }
};

byte rowPins[ROWS] = {

  4, 3, 2, 1};

byte colPins[COLS] = {

  13, 12, 11, 10 };

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

  


void setup() {
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
pinMode (0, INPUT);
boolean alarmState = 0;
keypad.setDebounceTime(50);
keypad.addEventListener(keypadEvent);
}

void loop() {
  noTone( 8 );

  if(alarmState == 1){
    if (digitalRead(0) == HIGH)(
    
    alarm();
  }
}
 else{
keypad.getKey();
 }
}

void keypadEvent(KeypadEvent eKey){

switch (keypad.getState()){

 case PRESSED:
    switch (eKey){
    case '#': 
      checkPassword();
      break;


        break;
      default:
        password.append(eKey);
    }

}

}

void checkPassword(){
  if (password.evaluate()){
    if (alarmState == 0){
      alarmState = 1;

      else{
        alarmState = 0
      }
    }
  }

else {
  loop();
}

}


void alarm(){

  for(int y=0; y<2; y++){
   
  for(int x=0; x<180; x++){
    sinVal =(sin(x*(3.1412/180)));

    toneVal = 1500+(int(sinVal*1000));
    brightness = int(sinVal*5);
    tone(8, toneVal);
    analogWrite(9, brightness);
    delay(2);
  }
 }
}

Remove the } on line 59.

If you use the AutoFormat tool to lay out your code then the imbalanced } will be immediately obvious.

Because of the unwanted } the function keypadEvent() is not being recognized by the compiler

...R

PS ... To make it easier for people to help you please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

Please edit your post and replace [quote] and [/quote] by [code] and [/code].

One thing you do wrong is calling loop(); you should never call loop().

Robin2:
Remove the } on line 59.

Don't do that.
Fix line 55 instead:

 if (digitalRead(0) == HIGH) (
                            ^^^

Good thing you are not using Serial. That would conflict with using Pin 1 for one of your rows.

You should almost certainly NOT be calling loop() from your checkPassword() function. Just return, and then keypadEvent() will return and loop() will continue.

And of course the '(' at the end of " if (digitalRead(0) == HIGH)(" should be a '{'.

oqibidipo:
Don't do that.
Fix line 55 instead:

 if (digitalRead(0) == HIGH) (

^^^

Because the OP has not used code tags it is just too much trouble to look at the code to see why you are saying that.

My wild guess is that there were at least 2 errors.

...R