Hi Russ,
The portal service has a set of APIs you can use: SAPUI5 SDK - Demo Kit. I'm not sure if and how you can actually catch specific events inside an application, but this should be a good start to understanding what's possible.
You should also familiarise yourself with the concept of Shell Plugins, which are simply SAPUI5 applications that can be loaded in the context of portal sites, and are usually used to control the behaviour of the portal's framework, like adding menu items or header buttons. You can use a shell plugin to run any code you wish 'in the background'. Read more about shell plugins here: SAP HANA Cloud Platform, Portal Service.
Thanks,
Guy