You can probably simplify this to a 2-liner via a ternary on m_keyLayout.  Not sure if there's a macro available for this common operation already - see GUIMessage.h