how to capture input from keypad?

Could some one please help me with my code . i would like to use my keypad with a password as a switch.
i am new to programing and i have only just have my key pad working finally hear is my current code

#include <Keypad.h>
byte rows = 4; //four rows
byte cols = 4; //four columns
byte rowPins[] = {4, 9, 8, 6}; //connect to the row pinouts of the keypad
byte colPins[] = {5, 3, 7, 0}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad(rowPins,colPins,rows,cols);

void setup(){
Serial.begin(9600);
}

void loop(){
char key = keypad.getKey();

if (key != NO_KEY){
Serial.println(key);
}
}
i would like to know how to modify this code to switch a digital output when a password is entred.
:slight_smile: