Same goes here.  A WORD is 2 BYTES so you only need `0xFF00` here but I think you just want the low-order NIBBLE of the high-order BYTE. According to the docs you only want bits 0-4,  bits 5-8 are reserved for the keyboard driver. so you need to mask off the high order NIBBLE. `(keyCode & 0x0F00)` 

Couldn't you just do a simple bit test?  `isAltGr = (keyCode & 0x60) == 0x60` ?