6

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.

HaNdTriX
  • 28,732
  • 11
  • 78
  • 85
  • 1
    No, it is not possible. `onInputChanged` should be sufficient for most use cases. Can you expand your question to explain what you're trying to do and clarify why `onInputChanged` is not sufficient for your needs? – apsillers Apr 12 '13 at 13:17
  • I have found that it's called `chrome.searchBox` now... anyone else find this has changed and which version? – marksyzm Apr 18 '13 at 08:25

1 Answers1

3

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

enhzflep
  • 12,927
  • 2
  • 32
  • 51
  • Oh, yes, yes indeed - enter pressed to confirm selection. There doesn't seem to be a notification until the option is chosen - just like an html `select` element or (if i remember correctly) a win32 combo-box. I guess the rationale being - the selection hasn't changed until a new selection is made. 'browsing' the selections is event-free. – enhzflep Apr 12 '13 at 17:24