{"id":237,"date":"2011-10-10T14:01:35","date_gmt":"2011-10-10T18:01:35","guid":{"rendered":"http:\/\/adamrosenfield.com\/blog\/?p=237"},"modified":"2011-11-28T00:11:34","modified_gmt":"2011-11-28T04:11:34","slug":"google-search-keyboard-shortcuts","status":"publish","type":"post","link":"http:\/\/adamrosenfield.com\/blog\/2011\/10\/10\/google-search-keyboard-shortcuts\/","title":{"rendered":"Google search keyboard shortcuts"},"content":{"rendered":"<p>For quite some time, <a href=\"http:\/\/www.google.com\/experimental\/index.html\">Google&#8217;s experimental search<\/a> offered a &#8220;Keyboard shortcuts&#8221; experiment, where you could navigate search results with vi-style key bindings (<em>j<\/em> and <em>k<\/em> to navigate up and down search results, <em>o<\/em> or <em>Enter<\/em> to open a link, and <em>\/<\/em> to move the cursor back to the search box).<\/p>\n<p>It seems they have recently removed that experiment, as they sometimes do.  I don&#8217;t know exactly when that happened, but <a href=\"http:\/\/web.archive.org\/web\/20110421185656\/http:\/\/www.google.com\/experimental\/index.html\">The Wayback Machine<\/a> puts it at somewhere between April 21 and now.  But despite Google&#8217;s removing the experiment, the keyboard shortcuts had still been working just fine for me\u2014until, 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&#8217;t like, such as highlighting the currently selected search result blue.<\/p>\n<p>I took a peek into the JavaScript on that page, and though it was optimized and obfuscated, it wasn&#8217;t enormously complicated.  It was doing stuff with the <code>PREF<\/code> cookie, but the cookie&#8217;s content was highly opaque.  There was a handy <code>_toggle()<\/code> 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 <code>'ImagesInstant::PublicOptIn'<\/code> and <code>'Axs'<\/code> to <code>_toggle()<\/code>.  Archive.org tells me that the keyboard shotcurts experiment used the name <code>'BetaShortcuts'<\/code>.<\/p>\n<p>So, the obvious next step was to see if running <code>_toggle('BetaShortcuts')<\/code> on that page would fix up my cookie to give me back my keyboard shortcuts.  I fired up the web console from Firefox&#8217;s <a href=\"https:\/\/addons.mozilla.org\/en-US\/firefox\/addon\/web-developer\/\">Web Developer add-on<\/a> and ran that command:<\/p>\n<pre>&gt; _toggle('BetaShortcuts')\r\nTypeError: h(\"e_\" + b) is null<\/pre>\n<p>D&#8217;oh.  It&#8217;s trying to do something with the page&#8217;s DOM\u2014ordinarily, when you click the &#8220;Join this experiment&#8221; button, it changes the button text to &#8220;Leave this experiment&#8221;, but there&#8217;s no button for the BetaShortcuts experiment to change the text for.  The <code>h()<\/code> function is just a thin wrapper around <code>document.getElementById()<\/code>.  Well, let&#8217;s try hacking around this by renaming one of the other buttons:<\/p>\n<pre>&gt; h(\"e_Axs\").id=\"e_BetaShortcuts\"\r\n\"e_BetaShortcuts\"\r\n&gt; _toggle('BetaShortcuts')\r\nundefined\r\nGET http:\/\/www.google.com\/url?(various opaque parameters) [HTTP\/1.1 204 No Content 88ms]<\/pre>\n<p>Close the page, and voila!  Keyboard shortcuts work again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For quite some time, Google&#8217;s experimental search offered a &#8220;Keyboard shortcuts&#8221; 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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-tools"],"_links":{"self":[{"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/comments?post=237"}],"version-history":[{"count":7,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"predecessor-version":[{"id":261,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions\/261"}],"wp:attachment":[{"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}