I would like to setup a keyboard shortcut/hotkey that would switch to Google Chrome and go to the omnibox (address bar). I intend to use it invoke various custom search engines.

I found a couple of related questions but not quite there:

I had done something like this with AutoHotKey on Windows. What's the right tool on the Mac?

I am already using Karabiner-Elements and Alfred.

  • I found karabiner-elements.pqrs.org/docs/json/… and set up a hotkey to switch to Google Chrome. However, I'm missing the last step -- how to put the cursor into the Address Bar. – Aleksey Tsalolikhin Mar 16 at 18:45
  • Most browsers use Cmd/L – Tetsujin Mar 16 at 18:51
  • Yes -- can I have Karabiner send Cmd/L to the browser for me? – Aleksey Tsalolikhin Mar 16 at 18:52
  • You could add activate "Google Chrome" to the head of the raise script, & keystroke "l" with command down to the end, then all you need do is add a keystroke for the whole thing saved as a Service. No 3rd party app required. – Tetsujin Mar 16 at 19:02
  • Thank you! Is apple.stackexchange.com/questions/39204/… the raise script? How do I save the thing as a Service? (Total noob question.) In the meantime, I found if I use open -n -a 'Google Chrome.app' in Karabiner, I get the desired effect as well. – Aleksey Tsalolikhin Mar 16 at 19:08

I think your task is ill-defined & what you have found so far overkill - (that this is because you are new to Mac means that's nothing to be ashamed of, we all start somewhere;) If all you need is to bring an app to the front & enable the location area you can do it in Applescript in 2 lines.

tell application "Google Chrome" to activate
tell application "System Events" to keystroke "l" using command down

perhaps with an optional delay 0.5 in between those lines in case it's a bit slow to come to the front.

The only difficulty is to make this key-commandable.

If you set this up as a Script event in Automator, then in previous OSes [I think up to Mojave, I haven't used anything newer] you could just define it as a Service. Once defined & saved, you can then call the Service using
System Prefs > Keyboard > Shortcuts > Services
I think this has changed since Catalina, but someone else would need to detail precisely how.
So long as you give it a shortcut that doesn't conflict with anything else, then simply hitting that shortcut will bring Chrome to the front [or launch it if it's not already running] & set the cursor into the search/location bar. It will do this on the current tab if one is already open, or make a new window if nothing was open.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .