search

Home  >  Q&A  >  body text

javascript - chrome plugin: listen for keypresses when address bar foucs

Problems encountered when making a chrome plug-in:

Is it possible to monitor shortcut keys (such as ctrl s) when the input focus is on the address bar to operate documents on the page?

仅有的幸福仅有的幸福2809 days ago526

reply all(1)I'll reply

  • 某草草

    某草草2017-05-19 10:23:53

    Shortcut key registration

          {
            "name": "My extension",
            ...
            "commands": {
              "toggle-feature-foo": {
                "suggested_key": {
                  "default": "Ctrl+Shift+5"
                },
                "description": "Toggle feature foo",
                "global": true
              }
            },
            ...
          }

    Monitor input

    chrome.omnibox.onInputStarted.addListener(function callback)

    Change some flags when typing, save them to storage.local, and then detect them during the shortcut onCommand

    reply
    0
  • Cancelreply