Keypad as game input device?
How do i use the Keypad.h library to get my keypad press to run one
line of code when i press a button and another line when i release the
button

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

  if (key != NO_KEY) {
    Serial.println(key);
  }

  if (keypad.isPressed('*'))
  {
  randomr = random(10, 2000);
  Serial.println(randomr);
  }

}

From the link: https://playground.arduino.cc/Code/Keypad/ you can find all the functions supported by the Keypad library.
One relevant function is
KeyState getState()

It returns the current state of any of the keys.
The four states supported are IDLE, PRESSED, RELEASED, and HOLD.
Hence you can use this function for the keys you are interested in.
Also, if helpful consider this function as well.
setHoldTime(unsigned int time)

Set the number of milliseconds the user will have to hold a button until the HOLD state is triggered.

You can find the keypad.h library in action here. I motivate you to also try the code with this online Arduino emulator
you already have a builtin function defined to get the status of the key pressed
void loop() {
  char key = keypad.getKey();

  if (key != NO_KEY) {
    Serial.println(key);
  }
}

I have a poorly taken screenshot for the same for your quick reference.
Original Arduino emulator link: (you can play with the logic)

https://wokwi.com/playground/keypad

Disclosure: We work at wokwi.com, to create interesting tools and libraries for the Arduino community 
https://github.com/wokwi
for a more free demonstration of the libraries:
https://github.com/wokwi/arduino-libraries