Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
Detect user's keyboard shortcut in a chrome extension

I am currently developing a chrome extension. Only, here I am confronted with a problem: I would like my extension to detect when the user performs a keyboard shortcut and that triggers a JS function. For that, my manifest.json file looks like this:

{
  "manifest_version": 3,
  "name": "name",
  "version": "1.0.0",

  "description": "description.",
  "icons":{
    "16": "img/logo16.png",
    "48": "img/logo48.png",
    "128": "img/logo128.png"
  },

  "permissions": [
    "storage",
    "activeTab",
    "scripting"
  ],
  "background": {
    "service_worker": "js/background.js"
  },
  "commands": {
    "Restart App": {
      "suggested_key": {
        "default": "Ctrl+Shift+6",
        "mac": "Command+Shift+6"
      },
      "description": "Restart my app (Debugging)"
    }
  }
}

My background.js file located in the js folder, contains this:

chrome.commands.onCommand.addListener(function (command)
{
    if (command == "Restart App")
    {
        chrome.runtime.reload();
    };
    alert('app restart success !');
});

Only, when I launch the extension and execute the keyboard shortcut, nothing happens, no error is reported.

Would you have any ideas, thank you in advance.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda