Adding escape shortcut to Window

I am trying to add an escape key shortcut to the window, which should close the window in the same fashion as the ‘X’ button does on the top right. (Note, I have googled but can’t seem to find anything that helps)

Here is my code:


public class InfoWindow extends Window implements Action.Handler {
    
    static final Action esc = new ShortcutAction("Close window",
            ShortcutAction.KeyCode.ESCAPE, null);
    static final Action[] actions = new Action[]
{esc};
    
    public InfoWindow(boolean success, String text) {
        setCaption("Success");
        if (!success) {
            setCaption("Error");
        }
        
        addComponent(new Label(text, Label.CONTENT_XHTML));
        setWidth("300px");
        setVisible(true);
        center();
        //grey out background
        setModal(true);
    }
    
    @Override
    public Action[] getActions(Object target, Object sender) {
        return actions;
    }
    
    @Override
    public void handleAction(Action action, Object sender, Object target) {
        if (action == esc) {
            close();
        }
    }
}

It seems like the Action.Handler is not registering correctly. The handleAction and getActions methods are not being fired at all, regardless of any key presses.

Can you please help point out where I have gone wrong?

Found the problem.

When I first setup Vaadin with Netbeans, it installed the plugin for 6.23. I upgraded the project to 7.0.3, and I now have the Button.addShortcutListener method.

I should be fine from here.