Let U be a unital ⋆-algebras and δ: U → U be a linear map behaving like a derivation or an anti-derivation at the following orthogonality conditions on elements of U: xy = 0, xy ⋆ = 0, xy = yx = 0 and xy ⋆ = y ⋆ x = 0. We characterize the map δ when U is a zero product determined algebra. Special characterizations are obtained when our results are applied to properly infinite W ⋆ -algebras and unital simple C ⋆ -algebras with a non-trivial idempotent.