Help with MRI scanner trigger, key suppression

Hi All,
I’m encountering an issue in my code where the trigger from the MR scanner sends input to my terminal, when I need to interact with it still. There was a key disabling function in PsychToolBox that looks like this (from an old script):

DisableKeysForKbCheck(KbName('5%'));

Is there anything similar in PsychoPy? Or does anyone have any easy fixes to do this simply in Python?
Thank you.

Ok, my solution was to use the keyboard library in Python with the following functions:

keyboard.block_key("5")
keyboard.unblock_key("5")

A bit wary of this solution though.