Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Chrome Extension open popup by command

I want to use a shortcut Ctrl + B to open popup.html of my extension, so I don't need to move the mouse and click.

I tried the commands config from Google document but it seems doesn't work. Does anyone know how to fix this? Below is my configuration (Note that I'm using manifest_version: 3)

manifest.json:

{
  "name": "",
  "description": "",
  "version": "0.0.1",
  "manifest_version": 3,
  "background": {
    "service_worker": "background.js"
  },
  "action": {
    "default_popup": "popup.html"
  },
"commands": {
    "_execute_action": {
      "suggested_key": {
        "default": "Ctrl+B",
        "mac": "Ctrl+B"
      }
    }
  }
}

popup.html

<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  Hello world
</body>
</html>

background.js

// Currently empty
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Don't know if this works for you, but if position of popup.html is not an issue for you this shall work if added to your background.js script. (executed on local host in manifest version 3)

manifest.json

 "commands": {
 "my_shortcut": {
  "suggested_key": {
    "default": "Ctrl+B",
    "mac": "Command+B"
  },
  "description": "Opens popup.html",
  "global": true
},
}

background.js

chrome.commands.onCommand.addListener((command) => {

if (command === 'my_shortcut')
    chrome.system.display.getInfo({ singleUnified: true }, (info) => {
    
      const wDimension = info[0].workArea;
      const { top, left, height, width } = wDimension;
      console.log(top);
      const w = 440;
      const h = 220;
      const l = width / 2 - w / 2 + left;
      const t = height / 2 - h / 2 + top;
      const newWindow = () => {
        console.log('in new window function');
      };
      chrome.windows.create(
        {
          url: 'popup.html',
          type: 'popup',
          width: w,
          height: h,
          left: Math.round(l),
          top: Math.round(t),
        },
        newWindow
      );
    });
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!