Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add keypress event to the omnibox in a chrome extension

Is it somehow possible to listen to keyevents (keyup, keydown, keypress) in the chrome omnibox?

So far I just found:

chrome.omnibox.onInputStarted.addListener(function() {...});
chrome.omnibox.onInputChanged.addListener(function(string text, function suggest) {...});
chrome.omnibox.onInputEntered.addListener(function(string text) {...});
chrome.omnibox.onInputCancelled.addListener(function() {...});

Edit:

The problem with the onInputChanged event is, that it doesn't fire, when the user uses the arrow keys to navigate to one of the suggestions.

like image 851
HaNdTriX Avatar asked Apr 12 '13 09:04

HaNdTriX


1 Answers

I haven't looked at the source, however, there's an example over here: http://developer.chrome.com/extensions/samples.html#be68e4d262d74d2457999fc402f5bf5e

I just tried it (type "omnix s" into the omnibox), and can report than when using the arrow keys to navigate to one of the suggestions that an alert is displayed, informing me of the selected option.

Note: This only works if the selected option displays the extension's icon next to it

like image 71
enhzflep Avatar answered Oct 20 '22 07:10

enhzflep