private static KeyStates GetKeyState(Keys key) { KeyStates state = KeyStates.None; short retVal = NativeImport.GetKeyState((int)key); if ((retVal & 0x8000) == 0x8000) { state |= KeyStates.Down; } if ((retVal & 1) == 1) { state |= KeyStates.Toggled; } return(state); }