google-chrome-extensionomnibox

Entering omnibox-mode programmatically


I want an extension to be controlled by the Omnibox. The chrome.omnibox API lets me register a keyword, but that means a lot of clicking or typing to get to the extension. For example, I have to Ctrl+L to select the omnibox, then type some letters for the extension and space/tab.

Can this "omnibox mode for my extension" be entered programmatically? I.e. is there an API call I can make that will take the user's keyboard focus to the omnibox in already switched mode to my extension? I just want to replace the sequence of clicks/typing with a single keyboard shortcut that will allow the user immediately interact with the extension via the omnibox.


Solution

  • This is not currently possible. I could see this being implemented in two ways: 1. As you suggest, by allowing the extension to enter omnibox programmatically. I'm not sure if that's a good idea - stealing keyboard focus could be annoying to the user, and a possible security risk. 2. By adding "enter omnibox mode" as a target for the commands API. That way the user can configure the keyboard shortcut or disable it entirely.