/// <summary> /// Helper method for running logic on a key change. /// </summary> /// <param name="key">Code of the key being changed</param> /// <param name="down">True if the key is being pressed down, false if being released.</param> protected void KeyChanged(KeyCodes key, bool down) { if (down) { switch (key) { case KeyCodes.LeftAlt: case KeyCodes.RightAlt: modifiers |= ModifierKeys.Alt; break; case KeyCodes.LeftShift: case KeyCodes.RightShift: modifiers |= ModifierKeys.Shift; break; case KeyCodes.LeftControl: case KeyCodes.RightControl: modifiers |= ModifierKeys.Control; break; } Axiom.Input.KeyEventArgs e = new Axiom.Input.KeyEventArgs(key, modifiers); OnKeyDown(e); } else { switch (key) { case KeyCodes.LeftAlt: case KeyCodes.RightAlt: modifiers &= ~ModifierKeys.Alt; break; case KeyCodes.LeftShift: case KeyCodes.RightShift: modifiers &= ~ModifierKeys.Shift; break; case KeyCodes.LeftControl: case KeyCodes.RightControl: modifiers &= ~ModifierKeys.Control; break; } Axiom.Input.KeyEventArgs e = new Axiom.Input.KeyEventArgs(key, modifiers); OnKeyUp(e); } }
/// <summary> /// Helper method for running logic on a key change. /// </summary> /// <param name="key">Code of the key being changed</param> /// <param name="down">True if the key is being pressed down, false if being released.</param> protected void KeyChanged( KeyCodes key, bool down ) { if ( down ) { switch ( key ) { case KeyCodes.LeftAlt: case KeyCodes.RightAlt: this.modifiers |= ModifierKeys.Alt; break; case KeyCodes.LeftShift: case KeyCodes.RightShift: this.modifiers |= ModifierKeys.Shift; break; case KeyCodes.LeftControl: case KeyCodes.RightControl: this.modifiers |= ModifierKeys.Control; break; } var e = new Axiom.Input.KeyEventArgs( key, this.modifiers ); OnKeyDown( e ); } else { switch ( key ) { case KeyCodes.LeftAlt: case KeyCodes.RightAlt: this.modifiers &= ~ModifierKeys.Alt; break; case KeyCodes.LeftShift: case KeyCodes.RightShift: this.modifiers &= ~ModifierKeys.Shift; break; case KeyCodes.LeftControl: case KeyCodes.RightControl: this.modifiers &= ~ModifierKeys.Control; break; } var e = new Axiom.Input.KeyEventArgs( key, this.modifiers ); OnKeyUp( e ); } }