You need a library that has a non-blocking call. Blocking calls are pretty much pointless for a microcontroller library. If you can write the equivalent of Serial libraries available() method for your keypad you can guard
all the calls to getKey() to avoid blocking.