@Override
    public boolean dispatchKeyEvent(KeyEvent keyEvent)
    {
        if (keyEvent.getID() != KeyEvent.KEY_PRESSED)
            return false;

        int keyCode = keyEvent.getKeyCode();
        State state = StateManager.getInstance().getState();

        if (keyCode == KeyEvent.VK_SPACE)
            state.doAction();
        else if (keyCode == KeyEvent.VK_ESCAPE)
            state.doCancel();
        else if (keyCode == KeyEvent.VK_N && (keyEvent.getModifiers() & KeyEvent.CTRL_MASK) != 0)
            state.doNewGame();
        else if (keyCode == KeyEvent.VK_P && (keyEvent.getModifiers() & KeyEvent.CTRL_MASK) != 0)
            SettingsDialog.getInstance().showDialog();

        return false;
    }