Hotkey to switch to Google Chrome and go to the omnibox (location bar)
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:
- hotkey to switch application -- TotalSpaces -- requires a trackpad, which I don't use -- my daily driver is the keyboard.
- Script to raise a single window to the front -- I don't know how bind an AppleScript script to a hotkey (I'm new to the Mac).
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 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.