Sunday, February 6, 2011

How to Make Your Caps Lock Key Search the Web, Chrome OS-Style

How to Make Your Caps Lock Key Search the Web, Chrome OS-Style 
We've shown you many alternate uses for your Caps Lock key in the past, but if you like the idea of Chrome OS' search key (which replaces Caps Lock on the CR-48), here's how emulate it on Windows and OS X.

These tricks for Windows and Mac use the shortcut-creating AutoHotkey and Quicksilver/AppleScript combo, respectively. Essentially, they'll make it so whenever you hit the Caps Lock key, Chrome will come to the front of you rother windows, open up a new tab, and highlight the address bar, so you can search the web with one keystroke. If Chrome isn't open, it will open it for you.
If you're on Windows, just add this code to your main AutoHotkey script:
Capslock::
SetTitleMatchMode, 2
If WinExist("ahk_class Chrome_WidgetWin_0")
{
WinActivate
WinWaitActive
Send ^t
Send ^l
}
else
{
Run "C:\Users\Whitson Gordon\AppData\Local\Google\Chrome\Application\chrome.exe"
sleep 100
Send ^t
Send ^l
}
return
+Capslock::Capslock
Note that you'll want to change Whitson Gordon to your own user name in the path to Google Chrome.
OS X, unfortuntaely, won't let you maps the Caps Lock key to a specific function alone. However, with a bit of tweaking, we can get it so a simple shortcut like Caps Lock+Space will work just fine. First, create a new AppleScript with this code as the body:
tell application "System Events"
tell application "Google Chrome" to activate
keystroke "t" using command down
keystroke "l" using command down
end tell
Now, head into System Preferences > Keybaord and hit the Modifier Keys button. Change the Caps Lock key to perform a different action (I chose Control). Open up Quicksilver and create a new trigger as described here. Use something like Control+Space as your Hot Key. Now, Caps Lock+Space will open up a search-ready Chrome for you. Photo by Alex Harden.
Update: If you're a Firefox user, AutoHotkey ninja Platypus Man has already created a tweaked version that works in Firefox. If you're using Firefox on the Mac, just replace "Google Chrome" with Firefox.

No comments: