input: ignore modifiers on MOUSE_LEAVE

Just in case something adds shift/alt/ctrl state to it.
input: remove minor code duplication
input: discard key history when a key is mapped

This is for the sake of multi-key combinations (see github issue #718).
Now a multi-key sequence isn't matched if any of the previous keys were
actually mapped.
input: make key binds order-independent again

This is for the sake of multi-key commands again. This could break:

   SPACE ignore
   SPACE-SPACE command

while this worked:

   SPACE-SPACE command
   SPACE ignore

The reason being that if the shorter command was first in the list,
it would obviously match, and searching was stopped.