private static int GetKeyState(Keys key) { int state = KEY_NONE; short retVal = GetKeyState((int)key); if ((retVal & 0x8000) == 0x8000) state |= KEY_DOWN; if ((retVal & 1) == 1) state |= KEY_TOGGLED; return state; }