Google search keyboard shortcuts

October 10, 2011

For quite some time, Google’s experimental search offered a “Keyboard shortcuts” experiment, where you could navigate search results with vi-style key bindings (j and k to navigate up and down search results, o or Enter to open a link, and / to move the cursor back to the search box).

It seems they have recently removed that experiment, as they sometimes do. I don’t know exactly when that happened, but The Wayback Machine puts it at somewhere between April 21 and now. But despite Google’s removing the experiment, the keyboard shortcuts had still been working just fine for me—until, that is, I revisited the page linked to in the first paragraph. Even just visiting that page, without taking any action, removed the shortcuts. The Accessible View experiment also provides similar keyboard shortcuts, but it does other things I don’t like, such as highlighting the currently selected search result blue.

I took a peek into the JavaScript on that page, and though it was optimized and obfuscated, it wasn’t enormously complicated. It was doing stuff with the PREF cookie, but the cookie’s content was highly opaque. There was a handy _toggle() function which took the name of a feature to toggle. The two currently available experiments, Instant on Images and Accessible View, which pass in the names 'ImagesInstant::PublicOptIn' and 'Axs' to _toggle(). Archive.org tells me that the keyboard shotcurts experiment used the name 'BetaShortcuts'.

So, the obvious next step was to see if running _toggle('BetaShortcuts') on that page would fix up my cookie to give me back my keyboard shortcuts. I fired up the web console from Firefox’s Web Developer add-on and ran that command:

> _toggle('BetaShortcuts')
TypeError: h("e_" + b) is null

D’oh. It’s trying to do something with the page’s DOM—ordinarily, when you click the “Join this experiment” button, it changes the button text to “Leave this experiment”, but there’s no button for the BetaShortcuts experiment to change the text for. The h() function is just a thin wrapper around document.getElementById(). Well, let’s try hacking around this by renaming one of the other buttons:

> h("e_Axs").id="e_BetaShortcuts"
"e_BetaShortcuts"
> _toggle('BetaShortcuts')
undefined
GET http://www.google.com/url?(various opaque parameters) [HTTP/1.1 204 No Content 88ms]

Close the page, and voila! Keyboard shortcuts work again.

11 Responses to “Google search keyboard shortcuts”

  1. Thenks! Easier way to enable this is to use bookmarklet or just enter this in address bar (when you are at http://www.google.com/experimental/index.html page)

    javascript:h(“e_Axs”).id=”e_BetaShortcuts”;_toggle(‘BetaShortcuts’)

  2. Hi! I’m going crazy now that I’ve got a new computer and can’t turn keyboard shortcuts back on.

    – I’ve tried using the Javascript snippet left in the comment section by _abc_. Doing this doesn’t do anything to my browser that I can see.

    – I found a blog post (http://www.ghacks.net/2011/03/31/google-experimental-search-explained/) that shows that it is possible to bring this feature back by adding “&esrch=BetaShortcuts” to the end of a search results URL. This works but it 1) adds an annoying yellow box to the top of the page and 2) I’m not sure how to make this a part of the Firefox search box.

    If you could build a little bookmarklet or give the steps on how to re-enable the feature using the javascript method suggested in the comment I would be incredibly thankful!!

  3. Al, did you try following the steps in my original post?

  4. Success! I wanted to avoid installing the Web Developer add-on since I’m not a developer and try to keep FF as slim as possible. But decided to bite the bullet: installed the add-on, followed the instructions and I have my keyboard shortcuts back!! (I’ve disabled the add-on since).

    I think a bookmarklet or a little snippet of javascript would make the lives of non-developers even easier, but this wasn’t too bad.

    Thanks for your help Adam!

  5. Well it seems Google has more seriously disabled this experiment. I did a normal google search a few days ago and got a message showing the experiment ended with a link to go to the experiments homepage.

    Tried following the instructions above again but it hasn’t worked.

    Adding &esrch=BetaShortcuts to the search string brings the shortcuts back, so this thing isn’t completely dead:
    http://blog.nqzero.com/2010/03/google-experimental-search-keyboard.html

  6. Yep, I’m seeing the same thing. It’s unfortunate. If you want to whip up a Greasemonkey script or Firefox add-on that automatically adds &esrch=BetaShortcuts to all searches, please share it by all means!

  7. I am at work, and not freely able to install add-ons in Firefox. I do, however, have Firebug installed, so I can run Javascript commands via the Console view.

    So…

    I load http://www.google.com/experimental/index.html
    Then I put:

    h(“e_Axs”).id=”e_BetaShortcuts”;
    _toggle(‘BetaShortcuts’);

    into the Console and hit Run…
    The statement executes, I see no error messages, and yet, nothing has changed. Am I missing something??

  8. Hi Marc, it unfortunately looks like Google has recently disabled the keyboard shortcuts experiment, see Al G’s comment.

  9. A new day, a new work-around that I’d like to suggest. I used the Mycroft Project to create a new Firefox search engine:
    http://mycroft.mozdev.org/submitos.html

    The result works well — has suggestions and brings in the keyboard shortcut by appending &esrch=BetaShortcuts to the search string. You can add this to your FF browser by going to:
    http://mycroft.mozdev.org/search-engines.html?author=Al+G

    It only works for the search box and not when searching directly from google.com, but for me this works well as the FF search box is where I do 99% of my searches.

    Hope that helps.

  10. Nice, thanks Al! I also do the vast majority of my searches from the FF search box, so that’s extremely helpful.

  11. no longer works. try this: http://goo.gl/UL2gh