private void thisForm_KeyUp(object sender, KeyEventArgs e)
 {
     if (downKeys.Remove(e.KeyCode) && _keyDownHandler != null)
     {
         _keyUpHandler.Invoke(e.KeyCode);
     }
 }
Example #2
0
        private void OnKeyEvent(object sender, KeyEventArgs e)
        {
            KeyEventHandler handler = (KeyEventHandler)eventDestination.Target;

            if (handler != null)
            {
                handler.Invoke(sender, e);
            }
            else
            {
                Deregister();
            }
        }
Example #3
0
        private static void GlobalEvent()
        {
            var currentEvent = Event.current;

            if (currentEvent != null)
            {
                UpdateInputState(currentEvent);
                if (currentEvent.type == EventType.KeyDown || currentEvent.type == EventType.KeyUp)
                {
                    _LastKeyEvent = currentEvent;

                    SetKeyDown(currentEvent.keyCode, currentEvent.type == EventType.KeyDown);

                    if (KeyEventHandler != null)
                    {
                        KeyEventHandler.Invoke();
                    }
                }
            }
        }
 private void Window_KeyUp(object sender, KeyEventArgs e)
 {
     SecondaryKeyUp?.Invoke(sender, e);
 }
Example #5
0
 /// <summary>
 /// Invokes event that says no key was pressed and what is actual reading position.
 /// </summary>
 /// <param name="position">actual reading position</param>
 protected virtual void OnKeyNotPressed(int position)
 {
     KeyEventHandler.Invoke(this, new GameEventArgs(position));
 }
Example #6
0
 /// <summary>
 /// Invokes event that says which key was pressed and what is actual reading position.
 /// </summary>
 /// <param name="key">pressed key</param>
 /// <param name="position">actual reading position</param>
 protected virtual void OnKeyPressed(char key, int position)
 {
     KeyEventHandler.Invoke(this, new GameEventArgs(position, key));
 }
 public static void RaiseKeyEvent(object objectRaisingEvent, KeyEventHandler keyEventHandlerRaised, KeyEventArgs keyEventArgs)
 {
     keyEventHandlerRaised?.Invoke(objectRaisingEvent, keyEventArgs); // Notify all subscribers
 }