private bool IsExactMatch() { HashSet <KeyModifier> modifiers = this.GetKeyModifiers(); HashSet <Key> keys = this.GetKeysPressed(); // No key must be pressed for the modifier None. if (this.Contains(KeyModifier.None)) { return((modifiers.Count == 0) && (keys.Count == 0)); } // Make sure every modifier has a matching key pressed. foreach (KeyModifier modifier in modifiers) { if (!KeyModifierCollection.IsKeyPressed(modifier, keys)) { return(false); } } // Make sure every key pressed has a matching modifier. foreach (Key key in keys) { if (!KeyModifierCollection.HasModifier(key, modifiers)) { return(false); } } return(true); }
private bool MatchAny() { if (this.Contains(KeyModifier.None)) { return(true); } HashSet <KeyModifier> modifiers = this.GetKeyModifiers(); HashSet <Key> keys = this.GetKeysPressed(); foreach (KeyModifier modifier in modifiers) { if (KeyModifierCollection.IsKeyPressed(modifier, keys)) { return(true); } } return(false); }