Add keypress event to the omnibox in a chrome extension
Asked Answered
C

1

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.

Cheryle answered 12/4, 2013 at 9:31 Comment(2)
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?Cytologist
I have found that it's called chrome.searchBox now... anyone else find this has changed and which version?Kuehl
I
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

Incorrupt answered 12/4, 2013 at 17:1 Comment(1)
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.Incorrupt

© 2022 - 2024 — McMap. All rights reserved.