You could use the OnLayoutKeystroke trigger to run a script that uses get ( activeFieldName ) to see if a field has the focus. If not, use exit script [false ] to cancel the keystroke before it can cause that error.
Do you have multiple windows open? If you have a window open that is not in layout mode and it pops into the foreground this can happen.
In addtion, if user want to navigate buttons with keyboard (tab and enter/space to push), need checking also
and this need the object to be named.
It would be nice that there is setting for avoid the alert (in layout setting or file option or application preferences).