Keyboard Listening in 3-Matic

I’m attempting to write a while loop that runs through a few lines of command over and over again until is pressed by the user. I’ve been trying to work with the keyboard module to do this. The functions I’ve tried so far are ‘is_pressed’ and ‘on_press_key’. Neither seem to work in 3-matic because they both sense being pressed before I’ve pressed it.

If there are any suggestions/code examples on how to achieve this, I’d greatly appreciate it.

Thank you in advance for your assistance,

Ian