Use the KeyCode to directly find the modifier mask. (Fix bug 5173)