How do I detect when UI events are triggered on *any object*?

I want to know when UI events are being triggered so I can intercept them and inject my own code.

To do this, I planned to add my own script to the object that has the EventSystem and StandaloneInputModule components, and that would use EventTriggers. However, I didn’t realise that EventTriggers need to be attached to the actual object that’s being manipulated (i.e. on each and every button in the canvas).

Instead, I want to add a ‘global detection system’ that tracks whenever navigation directions are pressed or any button is clicked, with “Submit” or “Cancel”, then fire off some events as I need to.

Thanks!

why you need to do this? isnt easier to create custom buttons that fire your methods? i mean if you need to inject your own code this is the easier solution. something like

 button.onClick.AddListener(() => ButtonClicked());

and create a method called ButtonClicked with all the code you want, you just need to add that listener to each button you want.