/// <summary>
        /// Registers a all keypress events and keeps track of keys being held down.
        /// </summary>
        static void HandleKeyInput()
        {
            if (Event.current.isKey)
            {
                var keyCode   = Event.current.keyCode;
                var eventType = Event.current.type;
                if (RexISM.InputBuffer.ContainsKey(keyCode))
                {
                    if (eventType == EventType.KeyUp)
                    {
                        RexISM.InputBuffer.Remove(keyCode);
                    }
                    else if (eventType == EventType.KeyDown &&
                             DateTime.Now >= RexISM.InputBuffer[keyCode].LastPressed + RexISM.KeyInput.DelayAmount)
                    {
                        RexISM.InputBuffer[keyCode].LastPressed = DateTime.Now;
                        RexISM.InputBuffer[keyCode].IsHandled   = false;
                    }
                }
                else if (eventType == EventType.KeyDown)
                {
                    foreach (var item in RexISM.InputBuffer.ToArray())
                    {
                        if (!item.Value.IsHandled && item.Value.LastPressed + RexISM.KeyInput.DelayAmount < DateTime.Now)
                        {
                            RexISM.InputBuffer.Remove(item.Key);
                        }
                    }

                    RexISM.PressKey(keyCode);
                }
            }
        }
 public static void PressKey(KeyCode key, int repeat = 1)
 {
     for (int i = 0; i < repeat; i++)
     {
         RexISM.PressKey(key);
         RexISM.Update();
     }
 }
 private void HandleTabKeyPress()
 {
     if (Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t')
     {
         if (RexISM.DisplayHelp)
         {
             RexISM.PressKey(KeyCode.Tab);
         }
         Event.current.Use();
     }
 }
        private void DisplayInputField(ref Rect inpLabelRect, ref Rect inpStringRect, ref Rect inpButRect)
        {
            GUI.Label(inpLabelRect, _texts["expression_header"]);
            var oldColor = ColorInput();

            GUI.SetNextControlName(NAME_OF_INPUT_FIELD);
            RexISM.Code = GUI.TextField(inpStringRect, RexISM.Code);

            //To have the cursor change to the 'I' on hover:
            GUI.color = Color.clear;
            EditorGUI.TextField(inpStringRect, "");
            GUI.color = oldColor;

            if (GUI.Button(inpButRect, _texts["evaluate_button"]))
            {
                GUI.FocusControl(NAME_OF_INPUT_FIELD);
                RexISM.PressKey(KeyCode.Return);
            }
        }