Yes, you can programmatically discard the event that is generated when the key is pressed. This can be done by using filter events in an Event structure. Discard the key event by passing a True value to the 'Discard?' boolean input on the Event Filter Node. The image below describes how the F1 key can be disabled using this method.
In this example, the F1 key press event will only be discarded when the above VI is run from the Front Panel (application focus is on Front Panel Window).