e.metaKey || (e.ctrlKey && !e.altKey)
seems to me like an exceptionally strange choice. Why not an exclusive-or? The thing they want to avoid is a false-positive on both being pressed, so test for that directly. e.metaKey || (e.ctrlKey && !e.altKey)
seems to me like an exceptionally strange choice. Why not an exclusive-or? The thing they want to avoid is a false-positive on both being pressed, so test for that directly.Also, Javascript doesn't have a logical xor operator, so trying to do that would potentially reduce readability.
I also didn't know about any operator to logically xor two boolean variables (thought about (ab)using JavaScript's implicit type conversion mechanisms: `x ^ y`), and then I learnt that `!=` works fine as a logical xor for booleans. Tada!
I don't know how much readability is reduced by this.
x != y
Even replacing the OR with XOR is not obviously an improvement as it is not clear that we know what the correct behavior would be in the edge case where a keyboard event is emitted with both the control and command flags set.