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[]
    public InfoWindow(boolean success, String text) {
        if (!success) {
        addComponent(new Label(text, Label.CONTENT_XHTML));
        //grey out background
    public Action[] getActions(Object target, Object sender) {
        return actions;
    public void handleAction(Action action, Object sender, Object target) {
        if (action == esc) {

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.