public SpecialKeyState CheckModifiers() { SpecialKeyState state = new SpecialKeyState(); if ((InterceptKeys.GetKeyState(VK_SHIFT) & 0x8000) != 0) { //SHIFT is pressed state.ShiftPressed = true; } if ((InterceptKeys.GetKeyState(VK_CONTROL) & 0x8000) != 0) { //CONTROL is pressed state.CtrlPressed = true; } if ((InterceptKeys.GetKeyState(VK_ALT) & 0x8000) != 0) { //ALT is pressed state.AltPressed = true; } if ((InterceptKeys.GetKeyState(VK_WIN) & 0x8000) != 0) { //WIN is pressed state.WinPressed = true; } return(state); }
private bool ModifierKeyPressed(Key key) { const int keyPressed = 0x8000; var pressed = Convert.ToBoolean(InterceptKeys.GetKeyState(key) & keyPressed); return(pressed); }