Exemplo n.º 1
0
        public static void KeyDown(KeyEventArgs e)
        {
            if (RedirectKeys && !e.KeyCode.Equals(keycodes[KeyInputs.escape]) && !e.KeyCode.Equals(keycodes[KeyInputs.console]))
            {
                if (DirectKeyCode != null)
                {
                    DirectKeyCode.Invoke(e.KeyCode);
                }
                return;
            }
            KeyInputs k = keycodes.FirstOrDefault(x => x.Value == e.KeyCode).Key; //Reverse lookup for the key based on the value given by the keycode event

            if (keysHeld.ContainsKey(k))                                          //If it's a key that should be held with others
            {
                if (!keysHeld[k])
                {
                    keysHeld[k] = true;
                    anyKeysHeld = true;
                }
            }
            else                        //If it's a one press key
            {
                if (ignoreKeys.Contains(k))
                {
                    return;
                }
                ManualKeys(new KeyInputs[] { k });
                if (InputCall != null)
                {
                    InputCall.Invoke(new KeyInputs[] { k });
                }
                ignoreKeys.Add(k);
            }
        }
Exemplo n.º 2
0
 public static void UpdateKeys()
 {
     if (anyKeysHeld)
     {
         List <KeyInputs> keys = new List <KeyInputs>();
         foreach (KeyInputs k in keysHeld.Keys)
         {
             if (keysHeld[k])
             {
                 keys.Add(k);
             }
         }
         if (InputCall != null)
         {
             InputCall.Invoke(keys.ToArray());
         }
         ManualKeys(keys.ToArray());
     }
 }