Trigger event after clicking on combination of two buttons

Trigger event after clicking on combination of two buttons

So I have a page with multiple buttons and I want something to happen once the user clicks on a specific combination of two buttons (for example, x happens if I click on button 1 and 3, y happens if I click on button 3 and 5). I nested the two click functions and it is not working. What am I doing wrong? Is there a simple and elegant solution?

Thank you!