How to listen to global events

How to filter global events? For example, I want to listen for the click events of all buttons in the application. When all buttons are clicked, the buzzer will sound.