Enter as a shortcut key


I’m evaluating Vaadin and I’m trying to create a simple searching gui for an already existing application. I have a page with a search form and a table that lists the results. I have a query object that I bind to the form. When user presses search button, the table is updated with the results.

It would be really great if pressing enter when editing the form would “click” the button. Before you direct me to the shortcut part in the Vaadin book, I already found it. The problem is that pressing enter doesn’t actually click the button. Can anyone spot what I’m doing wrong?

        Button searchButton = new Button("Hae");
        searchButton.addListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {

Hi Toni,

I tried this out with basically identical code to your code snippet and it worked as expected. Without any more details it’s hard to say where the problem is. Are you sure the
method is not run when you press enter?

  • Teemu

I tried debugging. The buttonclick gets called when using mouse but not on enter. If this is supposed to work then I’ll try looking if something else is wrong :slight_smile:

Hi, I’m experiencing the same issue. I added to my existing application the following line


and nothing happens when I press ENTER…

just tried a test case…

package com.example.enter;

import com.vaadin.Application;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

public class EnterApplication extends Application {
public void init() {
final Window mainWindow = new Window(“Enter Application”);

	Form f = new Form();		
	Button btn = new Button("Click me", new ClickListener() {
		public void buttonClick(ClickEvent event) {
			mainWindow.showNotification("Button was triggered");
	 * these dont work
	 * this one does


from the comments you can see that the clicklistener wont fire when the btn is added to the form’s footer.

Do you get the same results?


Please update to the latest bugfix version and your problem is solved.



I’m experiencing problems with .setClickShortcut.

I have my class, which in the end creates some object which draws a button which does some action when clicked. I have an action associated with it using .setClickShortcut(KeyCode.ENTER). I have several instances of this object instantiated, but the associated keypress only works on the 1st instance of this button.

Note that there should be no “confussion” on which button should be “fired” when pressing enter because my different instances of the object are distributed across different tabs, so there’s only one single different button visible each time.

Am I using this improperly? Maybe should I do this ClickShortcut setting explicitly to the button each time I change the visible/active tag?

We’ve not re-tried in over a year (Vaadin 7), but we had to disable our use of this for our multi-tab app as well. It seems that even though the other tabs are not visible, they were all still somehow active. So it worked for a single view app, but less so when wanting it to work per “Form” in a tabbed UI.

Thanks for your report, David. I’m on Vaadin 7, also.

I’ll try to explicitly enable/disable the key shortcut when entering/exiting the tab then. We’ll see if it works…