Skip to main content

KeyboardInputSource

A class in Root.Township, the global namespace.

InputSource driven by one keyboard key, so a key can act like a controller button for a PlayerInput.

Constructors​

MemberWhat it is
KeyboardInputSource(Key keyCode, PlayerInput controller)Creates a KeyboardInputSource from keyCode and controller.

Fields​

3 private and internal fields
MemberWhat it is
private PlayerInput controllerThe PlayerInput passed to the pressed and released events.
private IKeyBoardTriggerHandler pressedHandlerHandle for the key down registration.
private IKeyBoardTriggerHandler releasedHandlerHandle for the key up registration.

Properties​

MemberWhat it is
Key KeyCode { get; }The key this source listens to.

Methods​

MemberWhat it is
void AddListeners()Registers key down and key up handlers with KeyboardEventTriggers. Called by the constructor.
void RemoveListeners()Removes both key handlers.
2 private and internal methods
MemberWhat it is
private void KeyPressed(Key code)Fires the source's pressed event for the controller.
private void KeyUnpressed(Key code)Fires the source's released event for the controller.