0

I've been building a small Edge extension, just to see how it goes, I've done a few for Chrome in the past.

However, according to the Edge API docs, there's no support for the MDN "commands" manifest key to capture key presses.

What's the equivalent in Edge to achieve this? A keyboard listener in the background script maybe? I've seen other extensions capture key presses, e.g., LastPass with Alt+G to generate passwords and so on, so just wondering if anyone has found a solution to this?

Thanks.

1 Answers1

0

To achieve this you can inject a content script on every website or the websites you want to use this functionality with. In the content script you should listen for keyboard events and when you encounter expected keyboard event you can send a message to the background script. In the background script you can create a new tab with your extension's html page (like LastPass does it) or do something else as you wish.

You can use API runtime.sendMessage in Content Script to send a message to background script. In the background script you can use runtime.onMessage to listen for these messages. You can google these APIs and they are pretty straight-forward for the understanding.

To bind keyboard events you can refer this thread on StackOverflow:

JavaScript multiple keys pressed at once

WarPro
  • 350
  • 3
  • 5