Example #1
0
 public ShortcutDetails(string key, KeyboardModifiers modifiers = KeyboardModifiers.None)
 {
     Key        = key;
     HasAlt     = (modifiers & KeyboardModifiers.Alt) != 0;
     HasControl = (modifiers & KeyboardModifiers.Control) != 0;
     HasShift   = (modifiers & KeyboardModifiers.Shift) != 0;
 }
Example #2
0
 protected DragEventHandlerAttribute(Type requiredType, KeyboardModifiers modifiers, InputEventType eventType, EventPhase phase)
 {
     this.modifiers    = modifiers;
     this.eventType    = eventType;
     this.phase        = phase;
     this.requiredType = requiredType;
 }
Example #3
0
 public AcceleratorInfo(Control target, string text)
 {
     Target    = target;
     Text      = text;
     Key       = default(Keys);
     Modifiers = default(KeyboardModifiers);
 }
Example #4
0
 public ShortcutBinding(KeyboardModifiers modifiers, Key key, string context, CodeEditorCommand command)
 {
     Key       = key;
     Modifiers = modifiers;
     Context   = context;
     Command   = command;
 }
Example #5
0
 public MouseInputEvent(EventPropagator source, InputEventType type, KeyboardModifiers modifiers, bool isFocused, UIElement element)
 {
     this.source    = source;
     this.type      = type;
     this.modifiers = modifiers;
     this.element   = element;
 }
Example #6
0
        protected override void OnKeyPressInternal(IPointer cursor, KeyCodes code,
                                                   KeyboardModifiers modifiers, InputEventModifier eventModifiers)
        {
            base.OnKeyPressInternal(cursor, code, modifiers, eventModifiers);

            // We are focused.
            animationState.TransistTo(CommonStyleStates.Focused);

            if (code == KeyCodes.C && (modifiers & KeyboardModifiers.LCtrl) != 0)
            {
                if (selectedRange.Y < selectedRange.X)
                {
                    return;
                }

                // We have a copy event.
                Action3 <Label, Vector2i, StringBuilder> t = onTextCopy;
                StringBuilder b = new StringBuilder(SelectedText);

                // Events may alter copy or react on it.
                if (t != null)
                {
                    t(this, selectedRange, b);
                }

                // We add copy to cursor.
                AttachedData attachedData = new AttachedData();
                attachedData.ApplicationID  = Guid.Empty; //< FIXME
                attachedData.Data           = b.ToString();
                attachedData.Representation = null;

                // We attach data.
                cursor.AttachData(attachedData);
            }
        }
Example #7
0
 void SendKeyModifier(KeyboardModifiers sendKey)
 {
     try
     {
         //Check if the caps lock is enabled
         if (vCapsEnabled)
         {
             if (sendKey == KeyboardModifiers.ShiftLeft || sendKey == KeyboardModifiers.ShiftRight)
             {
                 vFakerInputDevice.KeyboardPressRelease(KeyboardModifiers.ControlLeft, KeyboardModifiers.None, KeyboardKeys.X, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None);
             }
             else if (sendKey == KeyboardModifiers.ControlLeft || sendKey == KeyboardModifiers.ControlRight)
             {
                 vFakerInputDevice.KeyboardPressRelease(KeyboardModifiers.ControlLeft, KeyboardModifiers.None, KeyboardKeys.C, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None);
             }
             else if (sendKey == KeyboardModifiers.AltLeft || sendKey == KeyboardModifiers.AltRight)
             {
                 vFakerInputDevice.KeyboardPressRelease(KeyboardModifiers.ControlLeft, KeyboardModifiers.None, KeyboardKeys.V, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None);
             }
             else if (sendKey == KeyboardModifiers.WindowsLeft || sendKey == KeyboardModifiers.WindowsRight)
             {
                 vFakerInputDevice.KeyboardPressRelease(KeyboardModifiers.ControlLeft, KeyboardModifiers.None, KeyboardKeys.A, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None);
             }
         }
         else
         {
             vFakerInputDevice.KeyboardPressRelease(sendKey, KeyboardModifiers.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None, KeyboardKeys.None);
         }
     }
     catch { }
 }
Example #8
0
        //Send the clicked button
        async Task KeyButtonClick(object sender)
        {
            try
            {
                PlayInterfaceSound(vConfigurationCtrlUI, "Click", false, false);

                Button sendButton  = sender as Button;
                Type   sendKeyType = sendButton.Tag.GetType();
                string sendKeyName = sendButton.Tag.ToString();
                if (sendKeyType == typeof(string))
                {
                    if (sendKeyName == "EmojiPopup")
                    {
                        await ShowHideEmojiListPopup();
                    }
                    else if (sendKeyName == "TextListPopup")
                    {
                        await ShowHideTextListPopup();
                    }
                }
                else
                {
                    if (sendKeyType == typeof(KeyboardKeys))
                    {
                        KeyboardKeys sendKey = (KeyboardKeys)sendButton.Tag;
                        Debug.WriteLine("Sending Keyboard key: " + sendKey);
                        SendKeyKeyboard(sendKey);
                    }
                    else if (sendKeyType == typeof(KeyboardModifiers))
                    {
                        KeyboardModifiers sendKey = (KeyboardModifiers)sendButton.Tag;
                        Debug.WriteLine("Sending Modifier key: " + sendKey);
                        SendKeyModifier(sendKey);
                    }
                    else if (sendKeyType == typeof(KeyboardMultimedia))
                    {
                        KeyboardMultimedia sendKey = (KeyboardMultimedia)sendButton.Tag;
                        Debug.WriteLine("Sending Multimedia key: " + sendKey);
                        if (sendKey == KeyboardMultimedia.VolumeMute)
                        {
                            await VolumeOutputMute();
                        }
                        else if (sendKey == KeyboardMultimedia.VolumeUp)
                        {
                            await VolumeUp();
                        }
                        else if (sendKey == KeyboardMultimedia.VolumeDown)
                        {
                            await VolumeDown();
                        }
                        else
                        {
                            SendKeyMultimedia(sendKey);
                        }
                    }
                }
            }
            catch { }
        }
Example #9
0
 public bool Matches(Key key, KeyboardModifiers activeModifiers)
 {
     if (key == Key.Oem2)
     {
         key = Key.Divide;
     }
     return(key == Key && activeModifiers == Modifiers);
 }
Example #10
0
		public DebugListener(string ident, ILifetimeObject owner,  Keys actionkey, KeyboardModifiers mod, DebugListenerType debugtype)
		{
			Identifier = ident;
			key = actionkey;
			modifiers = mod;
			type = debugtype;
			Owner = owner;
		}
Example #11
0
 public KeyboardInputEvent(EventPropagator source, InputEventType type, KeyCode keyCode, char character, KeyboardModifiers modifiers, bool isFocused)
 {
     this.source    = source;
     this.eventType = type;
     this.keyCode   = keyCode;
     this.modifiers = modifiers;
     this.character = character;
     this.isFocused = isFocused;
 }
        public MouseInputEvent(MouseInputAction action, float _x, float _y, float _z)
        {
            Action            = action;
            KeyboardModifiers = KeyboardModifiers.KeyboardModifierNone;

            x = _x;
            y = _y;
            z = _z;
        }
Example #13
0
 public AcceleratorInfo(Control target, Keys key, bool ctrl = false, bool alt = false, bool shift = false)
 {
     Target    = target;
     Text      = null;
     Key       = key;
     Modifiers = new KeyboardModifiers {
         LeftControl = ctrl, LeftAlt = alt, LeftShift = shift
     };
 }
 protected KeyboardInputBindingAttribute(KeyCode key, char character, KeyboardModifiers modifiers, InputEventType eventType, bool requiresFocusKeyEventPhase, EventPhase keyEventPhase)
 {
     this.key           = key;
     this.character     = character;
     this.modifiers     = modifiers;
     this.eventType     = eventType;
     this.requiresFocus = requiresFocusKeyEventPhase;
     this.keyEventPhase = keyEventPhase;
 }
 public void KeyPressCombo(KeyboardModifiers keyMod, KeyboardKeys keyPress)
 {
     try
     {
         KeysPress((byte)keyMod, (byte)keyPress, 0, 0, 0, 0, 0);
         Thread.Sleep(50);
         KeysRelease();
     }
     catch { }
 }
Example #16
0
 /// <summary>
 /// Event for buttons.
 /// </summary>
 /// <param name="owner"></param>
 /// <param name="buttonId"></param>
 /// <param name="state"></param>
 public InputEvent(InputDevice owner, uint buttonId, bool state,
                   InputEventModifier modifiers, KeyboardModifiers keyModifiers)
 {
     this.owner             = owner;
     this.type              = InputEventType.Button;
     this.stateRecord       = state ? 1 : 0;
     this.id                = buttonId;
     this.inputModifiers    = modifiers;
     this.keyboardModifiers = keyModifiers;
 }
Example #17
0
 private void UpdateModifier(bool isDown, KeyboardModifiers modifier)
 {
     if (isDown)
     {
         keyboardInputState.modifiersThisFrame |= modifier;
     }
     else
     {
         keyboardInputState.modifiersThisFrame &= ~modifier;
     }
 }
Example #18
0
        void IUserInteractive.OnKeyPress(IPointer cursor, KeyCodes code, KeyboardModifiers modifiers, InputEventModifier eventModifiers)
        {
            OnKeyPressInternal(cursor, code, modifiers, eventModifiers);

            Action5 <Area, IPointer, KeyCodes, KeyboardModifiers, InputEventModifier> t = onKeyPressed;

            if (t != null)
            {
                t(this, cursor, code, modifiers, eventModifiers);
            }
        }
Example #19
0
        void IUserInteractive.OnKeyRelease(IPointer cursor, KeyCodes code, KeyboardModifiers modifiers)
        {
            OnKeyReleaseInternal(cursor, code, modifiers);

            Action4 <Area, IPointer, KeyCodes, KeyboardModifiers> t = onKeyReleased;

            if (t != null)
            {
                t(this, cursor, code, modifiers);
            }
        }
Example #20
0
		public static void AddPush(string ident, ILifetimeObject owner, Keys actionkey, KeyboardModifiers mod, Action<DebugListener> listenerEvent = null)
		{
			var upperIdent = ident.ToUpper();

			if (listeners.ContainsKey(upperIdent))
				listeners.Remove(upperIdent);

			var result = new DebugListener(ident, owner, actionkey, mod, DebugListener.DebugListenerType.Push);
			if (listenerEvent != null) result.SetEvent(listenerEvent);
			listeners.Add(upperIdent, result);
		}
Example #21
0
		public static void AddSwitch(string ident, ILifetimeObject owner, Keys actionkey, KeyboardModifiers mod, bool initial)
		{
			var upperIdent = ident.ToUpper();

			if (listeners.ContainsKey(upperIdent))
				listeners.Remove(upperIdent);

			var result = new DebugListener(ident, owner, actionkey, mod, DebugListener.DebugListenerType.Switch);
			result.Set(initial);
			listeners.Add(upperIdent, result);
		}
Example #22
0
        private InputID CreateInputID(Keys key, string label, bool ctrl = false, bool alt = false, bool shift = false)
        {
            var mods = new KeyboardModifiers {
                LeftAlt     = alt,
                LeftShift   = shift,
                LeftControl = ctrl
            };
            var result = GetInputID(key, mods);

            result.Label = label;
            return(result);
        }
Example #23
0
 public void AddDragCreator(KeyboardModifiers modifiers, bool requiresFocus, EventPhase phase, Func <MouseInputEvent, DragEvent> creator)
 {
     dragCreators   = dragCreators ?? new LightList <DragCreatorData>(1);
     handledEvents |= InputEventType.DragCreate;
     dragCreators.Add(new DragCreatorData()
     {
         eventPhase   = phase,
         keyCode      = 0,
         character    = '\0',
         requireFocus = requiresFocus,
         modifiers    = modifiers,
         handler      = creator
     });
 }
Example #24
0
        /// <summary>
        /// Handles keyboard input.
        /// </summary>
        /// <param name="clickData"></param>
        /// <param name="time"></param>
        public static void UpdateKeyboardInput(GameTime time)
        {
            GetChanges(out List <Keys> pressed, out List <Keys> down, out List <Keys> released);

            if (pressed.Count > 0)
            {
                int length = pressed.Count;
                for (int i = 0; i < length; i++)
                {
                    KeysPressed?.Invoke(null, pressed[i]);
                }
            }

            if (down.Count > 0)
            {
                int length = down.Count;
                for (int i = 0; i < length; i++)
                {
                    KeysDown?.Invoke(null, down[i]);
                }
            }

            if (released.Count > 0)
            {
                int length = released.Count;
                for (int i = 0; i < length; i++)
                {
                    KeysReleased?.Invoke(null, released[i]);
                }
            }

            KeyboardState keyboardState = Keyboard.GetState();

            Modifiers = KeyboardModifiers.None;

            if (keyboardState.IsKeyDown(Keys.LeftControl) || keyboardState.IsKeyDown(Keys.RightControl))
            {
                Modifiers |= KeyboardModifiers.Control;
            }

            if (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))
            {
                Modifiers |= KeyboardModifiers.Shift;
            }

            if (keyboardState.IsKeyDown(Keys.LeftAlt) || keyboardState.IsKeyDown(Keys.RightAlt))
            {
                Modifiers |= KeyboardModifiers.Alt;
            }
        }
Example #25
0
 public void AddKeyboardEvent(InputEventType eventType, KeyboardModifiers modifiers, bool requiresFocus, EventPhase phase, KeyCode keyCode, char character, Action <KeyboardInputEvent> handler)
 {
     handledEvents |= eventType;
     eventHandlers  = eventHandlers ?? new LightList <HandlerData>(2);
     eventHandlers.Add(new HandlerData()
     {
         eventType    = eventType,
         eventPhase   = phase,
         keyCode      = keyCode,
         character    = character,
         requireFocus = requiresFocus,
         modifiers    = modifiers,
         handlerFn    = handler
     });
 }
 public bool KeyboardPressRelease(KeyboardModifiers keyModifier0, KeyboardModifiers keyModifier1, KeyboardKeys key0, KeyboardKeys key1, KeyboardKeys key2, KeyboardKeys key3, KeyboardKeys key4, KeyboardKeys key5)
 {
     try
     {
         KeyboardPress(keyModifier0, keyModifier1, key0, key1, key2, key3, key4, key5);
         AVActions.TaskDelayMs(50);
         KeyboardReset();
         return(true);
     }
     catch
     {
         Debug.WriteLine("Failed to press and release keyboard keys.");
         return(false);
     }
 }
Example #27
0
        public string GetKeyboardModifiersName(KeyboardModifiers keyboardModifier, bool shortName)
        {
            try
            {
                switch (keyboardModifier)
                {
                case KeyboardModifiers.ControlLeft:
                case KeyboardModifiers.ControlRight:
                    if (shortName)
                    {
                        return("Ctrl");
                    }
                    else
                    {
                        return("Control");
                    }

                case KeyboardModifiers.ShiftLeft:
                case KeyboardModifiers.ShiftRight:
                    return("Shift");

                case KeyboardModifiers.AltLeft:
                case KeyboardModifiers.AltRight:
                    if (shortName)
                    {
                        return("Alt");
                    }
                    else
                    {
                        return("Alternate");
                    }

                case KeyboardModifiers.WindowsLeft:
                case KeyboardModifiers.WindowsRight:
                    if (shortName)
                    {
                        return("Win");
                    }
                    else
                    {
                        return("Windows");
                    }
                }
            }
            catch { }
            return(Enum.GetName(typeof(KeyboardModifiers), keyboardModifier));
        }
Example #28
0
 //Update key details
 void UpdateKeypadKeyDetails(KeyboardModifiers modifierKey0, KeyboardModifiers modifierKey1, KeyboardKeys virtualKey, TextBlock keyTextLabel)
 {
     try
     {
         if (modifierKey0 != KeyboardModifiers.None && modifierKey1 != KeyboardModifiers.None && virtualKey != KeyboardKeys.None)
         {
             keyTextLabel.Text    = vFakerInputDevice.GetKeyboardModifiersName(modifierKey0, true) + "\n" + vFakerInputDevice.GetKeyboardModifiersName(modifierKey1, true) + "\n" + vFakerInputDevice.GetKeyboardKeysName(virtualKey, true);
             keyTextLabel.Opacity = 1;
         }
         else if (modifierKey0 != KeyboardModifiers.None && modifierKey1 != KeyboardModifiers.None)
         {
             keyTextLabel.Text    = vFakerInputDevice.GetKeyboardModifiersName(modifierKey0, true) + "\n" + vFakerInputDevice.GetKeyboardModifiersName(modifierKey1, true);
             keyTextLabel.Opacity = 1;
         }
         else if (modifierKey0 != KeyboardModifiers.None && virtualKey != KeyboardKeys.None)
         {
             keyTextLabel.Text    = vFakerInputDevice.GetKeyboardModifiersName(modifierKey0, true) + "\n" + vFakerInputDevice.GetKeyboardKeysName(virtualKey, true);
             keyTextLabel.Opacity = 1;
         }
         else if (modifierKey1 != KeyboardModifiers.None && virtualKey != KeyboardKeys.None)
         {
             keyTextLabel.Text    = vFakerInputDevice.GetKeyboardModifiersName(modifierKey1, true) + "\n" + vFakerInputDevice.GetKeyboardKeysName(virtualKey, true);
             keyTextLabel.Opacity = 1;
         }
         else if (modifierKey0 != KeyboardModifiers.None)
         {
             keyTextLabel.Text    = vFakerInputDevice.GetKeyboardModifiersName(modifierKey0, true);
             keyTextLabel.Opacity = 1;
         }
         else if (modifierKey1 != KeyboardModifiers.None)
         {
             keyTextLabel.Text    = vFakerInputDevice.GetKeyboardModifiersName(modifierKey1, true);
             keyTextLabel.Opacity = 1;
         }
         else if (virtualKey != KeyboardKeys.None)
         {
             keyTextLabel.Text    = vFakerInputDevice.GetKeyboardKeysName(virtualKey, true);
             keyTextLabel.Opacity = 1;
         }
         else
         {
             keyTextLabel.Text    = "?";
             keyTextLabel.Opacity = 0;
         }
     }
     catch { }
 }
Example #29
0
        static KeyboardModifiers GetModifiers()
        {
            KeyboardModifiers result = KeyboardModifiers.None;

            if (Modifiers.AltDown)
            {
                result |= KeyboardModifiers.Alt;
            }
            if (Modifiers.CtrlDown)
            {
                result |= KeyboardModifiers.Ctrl;
            }
            if (Modifiers.ShiftDown)
            {
                result |= KeyboardModifiers.Shift;
            }
            return(result);
        }
        public bool KeyboardPress(KeyboardModifiers keyModifier0, KeyboardModifiers keyModifier1, KeyboardKeys key0, KeyboardKeys key1, KeyboardKeys key2, KeyboardKeys key3, KeyboardKeys key4, KeyboardKeys key5)
        {
            try
            {
                FAKERINPUT_CONTROL_REPORT_HEADER structHeader = new FAKERINPUT_CONTROL_REPORT_HEADER();
                structHeader.ReportID     = (byte)FAKERINPUT_REPORT_ID.REPORTID_CONTROL;
                structHeader.ReportLength = (byte)Marshal.SizeOf(typeof(FAKERINPUT_KEYBOARD_REPORT));
                byte[] headerArray = ConvertToByteArray(structHeader);

                FAKERINPUT_KEYBOARD_REPORT structInput = new FAKERINPUT_KEYBOARD_REPORT();
                structInput.ReportID      = (byte)FAKERINPUT_REPORT_ID.REPORTID_KEYBOARD;
                structInput.ModifierCodes = (byte)(keyModifier0 | keyModifier1);
                structInput.KeyCodes      = new byte[] { (byte)key0, (byte)key1, (byte)key2, (byte)key3, (byte)key4, (byte)key5 };
                byte[] inputArray = ConvertToByteArray(structInput);

                return(WriteBytesFile(MergeHeaderInputByteArray(CONTROL_REPORT_SIZE, headerArray, inputArray)));
            }
            catch
            {
                Debug.WriteLine("Failed to press keyboard key.");
                return(false);
            }
        }
Example #31
0
 //Generate keypad tool tip
 string GenerateKeypadKeyToolTip(KeyboardModifiers modifierKey0, KeyboardModifiers modifierKey1, KeyboardKeys virtualKey, string keyName)
 {
     try
     {
         if (modifierKey0 != KeyboardModifiers.None && modifierKey1 != KeyboardModifiers.None && virtualKey != KeyboardKeys.None)
         {
             return(keyName + " is mapped to " + vFakerInputDevice.GetKeyboardModifiersName(modifierKey0, false) + " / " + vFakerInputDevice.GetKeyboardModifiersName(modifierKey1, false) + " / " + vFakerInputDevice.GetKeyboardKeysName(virtualKey, false));
         }
         else if (modifierKey0 != KeyboardModifiers.None && modifierKey1 != KeyboardModifiers.None)
         {
             return(keyName + " is mapped to " + vFakerInputDevice.GetKeyboardModifiersName(modifierKey0, false) + " / " + vFakerInputDevice.GetKeyboardModifiersName(modifierKey1, false));
         }
         else if (modifierKey0 != KeyboardModifiers.None && virtualKey != KeyboardKeys.None)
         {
             return(keyName + " is mapped to " + vFakerInputDevice.GetKeyboardModifiersName(modifierKey0, false) + " / " + vFakerInputDevice.GetKeyboardKeysName(virtualKey, false));
         }
         else if (modifierKey1 != KeyboardModifiers.None && virtualKey != KeyboardKeys.None)
         {
             return(keyName + " is mapped to " + vFakerInputDevice.GetKeyboardModifiersName(modifierKey1, false) + " / " + vFakerInputDevice.GetKeyboardKeysName(virtualKey, false));
         }
         else if (modifierKey0 != KeyboardModifiers.None)
         {
             return(keyName + " is mapped to " + vFakerInputDevice.GetKeyboardModifiersName(modifierKey0, false));
         }
         else if (modifierKey1 != KeyboardModifiers.None)
         {
             return(keyName + " is mapped to " + vFakerInputDevice.GetKeyboardModifiersName(modifierKey1, false));
         }
         else if (virtualKey != KeyboardKeys.None)
         {
             return(keyName + " is mapped to " + vFakerInputDevice.GetKeyboardKeysName(virtualKey, false));
         }
     }
     catch { }
     return(keyName + " is not mapped");
 }
Example #32
0
 public OnMouseClickAttribute(KeyboardModifiers modifiers = KeyboardModifiers.None, EventPhase phase = EventPhase.Bubble)
     : base(modifiers, InputEventType.MouseClick, phase)
 {
 }
Example #33
0
		public bool IsShortcutPressed(KeyboardModifiers mod, Keys key)
		{
			return IsModifierDown(mod) && IsKeyDown(key);
		}
        private static char? ToChar(Keys key, KeyboardModifiers modifiers = KeyboardModifiers.None)
        {
            var isShiftDown = ((modifiers & KeyboardModifiers.Shift) == KeyboardModifiers.Shift);

            if (key == Keys.A) { return isShiftDown ? 'A' : 'a'; }
            if (key == Keys.B) { return isShiftDown ? 'B' : 'b'; }
            if (key == Keys.C) { return isShiftDown ? 'C' : 'c'; }
            if (key == Keys.D) { return isShiftDown ? 'D' : 'd'; }
            if (key == Keys.E) { return isShiftDown ? 'E' : 'e'; }
            if (key == Keys.F) { return isShiftDown ? 'F' : 'f'; }
            if (key == Keys.G) { return isShiftDown ? 'G' : 'g'; }
            if (key == Keys.H) { return isShiftDown ? 'H' : 'h'; }
            if (key == Keys.I) { return isShiftDown ? 'I' : 'i'; }
            if (key == Keys.J) { return isShiftDown ? 'J' : 'j'; }
            if (key == Keys.K) { return isShiftDown ? 'K' : 'k'; }
            if (key == Keys.L) { return isShiftDown ? 'L' : 'l'; }
            if (key == Keys.M) { return isShiftDown ? 'M' : 'm'; }
            if (key == Keys.N) { return isShiftDown ? 'N' : 'n'; }
            if (key == Keys.O) { return isShiftDown ? 'O' : 'o'; }
            if (key == Keys.P) { return isShiftDown ? 'P' : 'p'; }
            if (key == Keys.Q) { return isShiftDown ? 'Q' : 'q'; }
            if (key == Keys.R) { return isShiftDown ? 'R' : 'r'; }
            if (key == Keys.S) { return isShiftDown ? 'S' : 's'; }
            if (key == Keys.T) { return isShiftDown ? 'T' : 't'; }
            if (key == Keys.U) { return isShiftDown ? 'U' : 'u'; }
            if (key == Keys.V) { return isShiftDown ? 'V' : 'v'; }
            if (key == Keys.W) { return isShiftDown ? 'W' : 'w'; }
            if (key == Keys.X) { return isShiftDown ? 'X' : 'x'; }
            if (key == Keys.Y) { return isShiftDown ? 'Y' : 'y'; }
            if (key == Keys.Z) { return isShiftDown ? 'Z' : 'z'; }

            if ((key == Keys.D0 && !isShiftDown) || key == Keys.NumPad0) { return '0'; }
            if ((key == Keys.D1 && !isShiftDown) || key == Keys.NumPad1) { return '1'; }
            if ((key == Keys.D2 && !isShiftDown) || key == Keys.NumPad2) { return '2'; }
            if ((key == Keys.D3 && !isShiftDown) || key == Keys.NumPad3) { return '3'; }
            if ((key == Keys.D4 && !isShiftDown) || key == Keys.NumPad4) { return '4'; }
            if ((key == Keys.D5 && !isShiftDown) || key == Keys.NumPad5) { return '5'; }
            if ((key == Keys.D6 && !isShiftDown) || key == Keys.NumPad6) { return '6'; }
            if ((key == Keys.D7 && !isShiftDown) || key == Keys.NumPad7) { return '7'; }
            if ((key == Keys.D8 && !isShiftDown) || key == Keys.NumPad8) { return '8'; }
            if ((key == Keys.D9 && !isShiftDown) || key == Keys.NumPad9) { return '9'; }

            if (key == Keys.D0 && isShiftDown) { return ')'; }
            if (key == Keys.D1 && isShiftDown) { return '!'; }
            if (key == Keys.D2 && isShiftDown) { return '@'; }
            if (key == Keys.D3 && isShiftDown) { return '#'; }
            if (key == Keys.D4 && isShiftDown) { return '$'; }
            if (key == Keys.D5 && isShiftDown) { return '%'; }
            if (key == Keys.D6 && isShiftDown) { return '^'; }
            if (key == Keys.D7 && isShiftDown) { return '&'; }
            if (key == Keys.D8 && isShiftDown) { return '*'; }
            if (key == Keys.D9 && isShiftDown) { return '('; }

            if (key == Keys.Space) { return ' '; }
            if (key == Keys.Tab) { return '\t'; }
            if (key == Keys.Enter) { return (char)13; }
            if (key == Keys.Back) { return (char)8; }

            if (key == Keys.Add) { return '+'; }
            if (key == Keys.Decimal) { return '.'; }
            if (key == Keys.Divide) { return '/'; }
            if (key == Keys.Multiply) { return '*'; }
            if (key == Keys.OemBackslash) { return '\\'; }
            if (key == Keys.OemComma && !isShiftDown) { return ','; }
            if (key == Keys.OemComma && isShiftDown) { return '<'; }
            if (key == Keys.OemOpenBrackets && !isShiftDown) { return '['; }
            if (key == Keys.OemOpenBrackets && isShiftDown) { return '{'; }
            if (key == Keys.OemCloseBrackets && !isShiftDown) { return ']'; }
            if (key == Keys.OemCloseBrackets && isShiftDown) { return '}'; }
            if (key == Keys.OemPeriod && !isShiftDown) { return '.'; }
            if (key == Keys.OemPeriod && isShiftDown) { return '>'; }
            if (key == Keys.OemPipe && !isShiftDown) { return '\\'; }
            if (key == Keys.OemPipe && isShiftDown) { return '|'; }
            if (key == Keys.OemPlus && !isShiftDown) { return '='; }
            if (key == Keys.OemPlus && isShiftDown) { return '+'; }
            if (key == Keys.OemMinus && !isShiftDown) { return '-'; }
            if (key == Keys.OemMinus && isShiftDown) { return '_'; }
            if (key == Keys.OemQuestion && !isShiftDown) { return '/'; }
            if (key == Keys.OemQuestion && isShiftDown) { return '?'; }
            if (key == Keys.OemQuotes && !isShiftDown) { return '\''; }
            if (key == Keys.OemQuotes && isShiftDown) { return '"'; }
            if (key == Keys.OemSemicolon && !isShiftDown) { return ';'; }
            if (key == Keys.OemSemicolon && isShiftDown) { return ':'; }
            if (key == Keys.OemTilde && !isShiftDown) { return '`'; }
            if (key == Keys.OemTilde && isShiftDown) { return '~'; }
            if (key == Keys.Subtract) { return '-'; }

            return null;
        }
Example #35
0
 public void SetKeyUp(char character, KeyboardModifiers modifiers = 0)
 {
     ProcessKeyboardEvent(0, InputEventType.KeyUp, character, modifiers);
 }
Example #36
0
		public bool IsModifierDown(KeyboardModifiers mod)
		{
			bool needsCtrl  = (mod & KeyboardModifiers.Control) == KeyboardModifiers.Control;
			bool needsShift = (mod & KeyboardModifiers.Shift)   == KeyboardModifiers.Shift;
			bool needsAlt   = (mod & KeyboardModifiers.Alt)     == KeyboardModifiers.Alt;

			bool down = true;

			down &= ! needsCtrl  || IsKeyDown(Keys.LeftControl) || IsKeyDown(Keys.RightControl);
			down &= ! needsShift || IsKeyDown(Keys.LeftShift)   || IsKeyDown(Keys.RightShift);
			down &= ! needsAlt   || IsKeyDown(Keys.LeftAlt)     || IsKeyDown(Keys.RightAlt);
			
			return down;
		}