ENTER shortcut on button for active panel

Let’s say we have multiple panels on a page, or multiple tabs. So let’s say I have save buttons on each panel/tab, each one saving data for contents of that particular panel or tab. To make life easier for the users, I have save.setClickShortcut(KeyCode.ENTER); for the save button in each panel/tab. How do I make sure the Click listener is only triggered for the container in which the “save” button exists?

What I ended up doing was the following inside the “setVisible” of the component in question:

if( visible )

Maybe not ideal, but best idea I could come up with.

Personally, I think I should have stayed away from applying the shortcut to the button and instead only applied it to the data entry fields for the form. Maybe Vaadin 8 or 10 give us better options, but that is not an option for me right now.