I'm cautious of making a statement on operator precedence, but I think a pair of parentheses would be helpful here:

```[event_key != k and (event_mods & m) == m]```

if I'm not mistaken?