diff --git a/web/pgadmin/static/js/keyboard_shortcuts.js b/web/pgadmin/static/js/keyboard_shortcuts.js
index c021d1830..f02851720 100644
--- a/web/pgadmin/static/js/keyboard_shortcuts.js
+++ b/web/pgadmin/static/js/keyboard_shortcuts.js
@@ -199,6 +199,7 @@ function keyboardShortcutsQueryTool(
   let commitKeys = sqlEditorController.preferences.commit_transaction;
   let rollbackKeys = sqlEditorController.preferences.rollback_transaction;
   let saveDataKeys = sqlEditorController.preferences.save_data;
+  let queryToolKeys = sqlEditorController.preferences.show_query_tool;
 
   if (this.validateShortcutKeys(executeKeys, event)) {
     this._stopEventPropagation(event);
@@ -230,6 +231,9 @@ function keyboardShortcutsQueryTool(
   } else if (this.validateShortcutKeys(saveDataKeys, event)) {
     this._stopEventPropagation(event);
     queryToolActions.saveDataChanges(sqlEditorController);
+  } else if (this.validateShortcutKeys(queryToolKeys, event)) {
+    this._stopEventPropagation(event);
+    queryToolActions.openQueryTool(sqlEditorController);
   } else if ((
     (this.isMac() && event.metaKey) ||
      (!this.isMac() && event.ctrlKey)
diff --git a/web/pgadmin/static/js/sqleditor/query_tool_actions.js b/web/pgadmin/static/js/sqleditor/query_tool_actions.js
index a97582e6a..98297cf18 100644
--- a/web/pgadmin/static/js/sqleditor/query_tool_actions.js
+++ b/web/pgadmin/static/js/sqleditor/query_tool_actions.js
@@ -161,6 +161,14 @@ let queryToolActions = {
     sqlEditorController.close_on_save = false;
     sqlEditorController.save_data();
   },
+
+  openQueryTool: function (sqlEditorController) {
+    sqlEditorController.gridView.handler.trigger(
+      'pgadmin-sqleditor:button:show_query_tool',
+      sqlEditorController.gridView,
+      sqlEditorController.gridView.handler
+    );
+  },
 };
 
 module.exports = queryToolActions;
diff --git a/web/pgadmin/static/js/sqleditor/query_tool_preferences.js b/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
index 5a3d15582..ba4e7c882 100644
--- a/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
+++ b/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
@@ -136,6 +136,12 @@ function updateUIPreferences(sqlEditor) {
     .attr('aria-label',
       shortcut_title(gettext('Rollback'),preferences.rollback_transaction));
 
+  $el.find('#btn-show-query-tool')
+    .attr('title',
+      shortcut_title(gettext('Query tool'),preferences.show_query_tool))
+    .attr('aria-label',
+      shortcut_title(gettext('Query tool'),preferences.show_query_tool));
+
   /* Set explain options on query editor */
   if (preferences.explain_verbose){
     $el.find('.explain-verbose').removeClass('visibility-hidden');
diff --git a/web/pgadmin/tools/datagrid/static/js/show_query_tool.js b/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
index 782bf78e3..9e0723665 100644
--- a/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
+++ b/web/pgadmin/tools/datagrid/static/js/show_query_tool.js
@@ -65,7 +65,15 @@ export function showQueryTool(datagrid, pgBrowser, alertify, url, aciTreeIdentif
 
   const gridUrl = generateUrl(transId, queryToolTitle, parentData);
 
-  datagrid.launch_grid(transId, gridUrl, true, queryToolTitle, sURL);
+  let retVal = datagrid.launch_grid(transId, gridUrl, true, queryToolTitle, sURL);
+  if(!retVal) {
+    alertify.alert(
+      gettext('Query tool launch error'),
+      gettext(
+        'Please allow the pop ups if they are blocked for pgAdmin. If the pgAdmin window is closed then close this window and open a new pgAdmin session.'
+      )
+    );
+  }
 }
 
 export function generateScript(parentData, datagrid) {
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index ae240cd5c..e81a42a47 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -17,7 +17,6 @@
             <div class="btn-group mr-1" role="group" aria-label="">
                 <button id="btn-show-query-tool" type="button" class="btn btn-sm btn-primary-icon btn-show-query-tool"
                         title=""
-                        accesskey=""
                         tabindex="0">
                     <i class="pg-font-icon icon-query-tool" aria-hidden="true" role="img"></i>
                 </button>
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 060207202..b0d5a118f 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -7,6 +7,8 @@
 //
 //////////////////////////////////////////////////////////////
 
+import {getTreeNodeHierarchyFromIdentifier} from 'sources/tree/pgadmin_tree_node';
+
 define('tools.querytool', [
   'sources/gettext', 'sources/url_for', 'jquery', 'jquery.ui',
   'jqueryui.position', 'underscore', 'pgadmin.alertifyjs',
@@ -151,7 +153,8 @@ define('tools.querytool', [
 
     reflectPreferences: function() {
       let self = this,
-        browser = pgWindow.default.pgAdmin.Browser;
+        browser = pgWindow.default.pgAdmin.Browser,
+        browser_preferences = browser.get_preferences_for_module('browser');
 
       /* pgBrowser is different obj from pgWindow.default.pgAdmin.Browser
        * Make sure to get only the latest update. Older versions will be discarded
@@ -162,6 +165,7 @@ define('tools.querytool', [
       if(pgBrowser.preference_version() < browser.preference_version()){
         pgBrowser.preference_version(browser.preference_version());
         self.preferences = browser.get_preferences_for_module('sqleditor');
+        self.preferences.show_query_tool = browser_preferences.sub_menu_query_tool;
         self.handler.preferences = self.preferences;
         queryToolPref.updateUIPreferences(self);
       }
@@ -2078,12 +2082,20 @@ define('tools.querytool', [
     if(!d)
       return;
 
+    const parentData = getTreeNodeHierarchyFromIdentifier.call(pgWindow.default.pgAdmin.Browser, i);
+
+    if(!parentData) {
+      return;
+    }
+
+    let conn_param = parentData.database || parentData.server;
+
     var selected_tree_node = { t, i, d };
 
     if(!pgWindow.default.pgAdmin.selected_tree_map)
       pgWindow.default.pgAdmin.selected_tree_map = new Map();
 
-    pgWindow.default.pgAdmin.selected_tree_map.set(d._pid.toString(), selected_tree_node);
+    pgWindow.default.pgAdmin.selected_tree_map.set(conn_param._id.toString(), selected_tree_node);
   };
 
   _.extend(
@@ -4306,7 +4318,7 @@ define('tools.querytool', [
         var self = this;
 
         setTimeout(() => {
-          var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did);
+          var tree_node = pgWindow.default.pgAdmin.selected_tree_map.get(self.url_params.did || self.url_params.sid);
           if(self.preferences.new_browser_tab) {
             is_main_window_alive();
           }
