Updated version to be based on key mask combo, not on a key mask tuple. Requires testing