I do not know whether it is a bug or a feature, but I think it is annoying.
Pressing keys on keyboard (shortcut key, unassigned keys, ...) activates the viewport below the mouse pointer. Suppose you just want to open the material editor by pressing 'm' but as a side effect the active viewport will be changed (if the mouse pointer is over an inactive viewport).