The handling of debug keys is applied inconsistently depending on the screen the player is currently viewing. This can easily be tested by showing the GameModeSwitcherScreen (pressing F3 + F4) when within a chest screen, hopper screen, edit sign, or the pause screen. For the chest and hopper, the button combination will do nothing. However, for the sign and pause screen, it will kick you out and open the switcher.
The reason this happens is both a mix of KeyboardHandler#handleDebugKeys doing a lot of things at once and AbstractContainerScreen#keyPressed has its own custom handling of key inputs.
AbstractContainerScreen#keyPressed will functionally always return true, whether or not the key was actually used by anything within the container, meaning that all inputs will be considered ‘handled' by the screen. This behavior is not present in any other subclasses of Screen, where it leaves it up to the screen itself to determine what is considered ‘handled'.
KeyboardHandler#handleDebugKeys, meanwhile, performs a lot of different actions depending on what keys are pressed. Some of them should always occur on top of screens, such as toggling the charts (which do not show up in container screens), while others should only happen when in the game (like the gamemode switcher).
There are too many combinations to list, but the basic gist is that if it requires a combination of F3 plus another key, it will not work in container screens like chests and hoppers, but will work in everything else like the edit sign and pause screen.
I confirm the inconsistency.