Please see this post for an explanation how to capture key events and do not propagate them to the 3D viewer: Hide some controls or all controlls temporary - #2 by jan (M has key code 77, F 70).
The viewer has logic that should disable special key handling when some input form is in focus, if you have a scene for which this isn’t working, please share a link with us and we will take a look.