Sure it works but it’s not as intuitive as it could be (although it could be worse). As always readable code is more important than trying to shorten it as much as possible.
Well, it seems pretty intuitive to me (if you replace “keyw” by “up”, “keys” by “down”, that kind of stuff.) It shows clearly there can be only two states and the values of it.