KeyTrigger ClassDelta Engine Documentation
Trigger implementation for Keyboard events, just can be invoked. Use KeyMovementTrigger for direct movement, e.g. with cursor keys and KeyZoomTrigger for PageUp/Down zooming triggers. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Entities Entity
    DeltaEngine.Commands Trigger
      DeltaEngine.Commands InputTrigger
        DeltaEngine.Input KeyTrigger
          DeltaEngine.Input KeyMovementTrigger
          DeltaEngine.Input KeyZoomTrigger

Namespace: DeltaEngine.Input
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class KeyTrigger : InputTrigger

The KeyTrigger type exposes the following members.

Constructors

  NameDescription
Public methodKeyTrigger(Dictionary String, String )
Initializes a new instance of the KeyTrigger class
Public methodKeyTrigger(Key, State)
Initializes a new instance of the KeyTrigger class
Top
Methods

  NameDescription
Public methodAdd T  (Inherited from Entity.)
Public methodAddTag (Inherited from Entity.)
Public methodClearTags (Inherited from Entity.)
Public methodContains T  (Inherited from Entity.)
Public methodContainsBehavior T  (Inherited from Entity.)
Public methodContainsTag (Inherited from Entity.)
Protected methodDeactivate (Inherited from Entity.)
Public methodDispose (Inherited from Entity.)
Public methodGet T 
Gets a specific component, derived classes can return faster cached values (e.g. Entity2D) View code on GitHub
(Inherited from Entity.)
Protected methodGetActiveBehaviors (Inherited from Entity.)
Protected methodGetComponentsForSaving (Inherited from Entity.)
Public methodGetOrDefault T  (Inherited from Entity.)
Public methodGetTags (Inherited from Entity.)
Public methodInvoke (Inherited from Trigger.)
Public methodRemove T  (Inherited from Entity.)
Public methodRemoveTag (Inherited from Entity.)
Public methodSet (Inherited from Entity.)
Public methodSetComponents (Inherited from Entity.)
Public methodStart T  (Inherited from Entity.)
Protected methodStartInputDevice (Overrides InputTrigger StartInputDevice .)
Public methodStop T  (Inherited from Entity.)
Public methodToString (Inherited from Entity.)
Public methodUpdate (Inherited from Trigger.)
Top
Fields

  NameDescription
Protected fieldcomponents (Inherited from Entity.)
Public fieldInvoked (Inherited from Trigger.)
Top
Properties

  NameDescription
Public propertyIsActive (Inherited from Entity.)
Public propertyIsPauseable (Inherited from Trigger.)
Public propertyKey
Public propertyNumberOfComponents (Inherited from Entity.)
Public propertyState
Public propertyUpdatePriority (Inherited from Entity.)
Public propertyWasInvokedThisTick (Inherited from Trigger.)
Top
Remarks

Tests: DeltaEngine.Input.Tests.KeyTriggerTests
Examples

7 unit tests call DeltaEngine.Input.KeyTrigger
[Test]
public void PressEscapeToCloseWindow()
{
    new FontText(Font.Default, "Press ESC to close the window", Rectangle.One);
    new Command(() => Resolve<Window>().CloseAfterFrame()).Add(new KeyTrigger(Key.Escape,
        State.Pressed));
}
[Test]
public void PressEscapeToCloseWindowViaRegisteredCommands()
{
    new FontText(Font.Default, "Press ESC to close the window", Rectangle.One);
    Command.Register("Exit", new KeyTrigger(Key.Escape, State.Pressed));
    new Command("Exit", () => Resolve<Window>().CloseAfterFrame());
}
[Test]
public void PressCursorKeysToShowCircles()
{
    var centers = new[]
    {
        new Vector2D(0.5f, 0.4f), new Vector2D(0.5f, 0.6f), new Vector2D(0.3f, 0.6f),
        new Vector2D(0.7f, 0.6f)
    };
    var size = new Size(0.1f, 0.1f);
    CreateFontTexts(centers, size);
    AddCirclesAndInputCommands(centers, size);
}
See Also