Bit Masking

switch (0x3FF - REG_KEYINPUT)

That approach is less generic, as it requires that REG_KEYINPUT has to return something in its last 10 digits. The approach I gave you allows the returned bits to be anywhere (in REG_KEYINPUT).

And it is also quite easy to detect key changes.