Want to use a single 4*3 custom keypad

Hello I'm new here and know the basics of coding. I'm working on a project where I have to use a single 4*3 keypad for entering a password and then using the same keypad i want to control the motor only when a specific key on the keypad is pressed. for e.g the key no.2 is pressed it should rotate the motor in clockwise direction and for key no.8 in the counter-clockwise direction. The key which is pressed should remain high until it is released. Any and all help would be appreciated. A snippet of code will help too, I can develop the remaining code.

The key which is pressed should remain high until it is released.

Why?

Some Keypad libraries will give separate events for Pressed and Released. Start the motor when the button is pressed and stop the motor when the button is released. It's up to you to decide what to do when both buttons are pressed.