A class in Root.Township, the global namespace.
Static registry that calls handlers when keyboard keys are pressed or released, using the Unity Input System. One instance in the scene polls the tracked keys each frame and is only enabled while any key is registered.
Constructors
| Member | What it is |
|---|
KeyboardEventTriggers() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
4 private and internal fields
| Member | What it is |
|---|
private static List<Key> currentKeys | List of tracked keys, walked by Update. |
private static KeyboardEventTriggers instance | The scene component doing the polling. |
private static Logger logger | Logger for this class. |
private static Dictionary<Key, KeyboardEventTriggers.KeyTracker> mappedTrackers | Tracker holding the down and up handlers for each key. |
Methods
| Member | What it is |
|---|
static void DeRegisterKeyPressed(ref IKeyBoardTriggerHandler triggerHandler) | Removes a handler added by RegisterKeyPressed and nulls the handle. Stops tracking the key once it has no handlers left. |
static void RegisterKeyPressed(Key key, bool isDown, KeyEventHandler handler, out IKeyBoardTriggerHandler triggerHandler) | Adds a handler for a key going down or up and returns a handle for removing it. Gives a null handle if there's no keyboard. |
3 private and internal methods
| Member | What it is |
|---|
private void Awake() | Becomes the polling instance and enables itself only if keys are already registered. |
private void OnDestroy() | Clears the polling instance. |
private void Update() | Polls each tracked key and fires its down or up handlers for this frame. |