Sorry if I cannot always remember the event keycode for every key, sometimes I have to google :)

So I googled detect esc jquery. This query returned a nice set of results, and the first almost contained exactly what I was looking for. Almost.

The reason it did not return the exact page I was looking for was because the first result was a Stack Overflow question that had been marked as a duplicate.

How to detect escape key press with JavaScript or jQuery?

Since it was a duplicate I clicked through to the next answer (figuring the "original" post would be more informative - it was, but not by much).

Which keycode for escape key with jQuery

This is where something piqued my interest a little. What metric lead to the first result being the closed question?

Perhaps it was that the first title was a stronger exact match according to Google than the second one?

In this scenario, it seems this was the proper question to present as a good search result. However, there is one glaring issue with that:

closed text

Note that the closed as a duplicate text is what shows up in the search result text.

Perhaps google inferred that the duplicate was more relevant because it had a more recent date?

In this scenario, it also highlights the issue that newer questions getting closed as duplicates of older questions also suffer from having their content obscured.

I do not think that the order of question closure should be changed. But I do think that questions closed as duplicates should have their Google-facing text be their content and not some closure message if they are going to show up in the results.

  • 4
    Who knows what really goes on in the mind of Google?
    – user102937
    Nov 26, 2013 at 0:35
  • @RobertHarvey - Indeed :) However, I am fairly certain google didn't come up with the duplicate closure text out of the blue.
    – Travis J
    Nov 26, 2013 at 0:36
  • I quess that it may be caused by "status" word in a class name of div presented. It would be logical to present status of a page as it's excerpt. Well, that's just a guess, I wish we could know.
    – Mołot
    Nov 26, 2013 at 7:55

1 Answer 1


From what I can tell there are a few differences between the two versions (and between open and closed -- as duplicate -- in general).

As Robert Harvey notes, on Google's end, who knows? Well I certainly do not know. Here are some observations:

Open Graph description is purposefully obfuscated

Many of the search results I looked at for Stack Overflow quote the meta tag named og:description. They don't quote the entirety, and tend to skip around. The skipping is complex, but always present. It would seem that this is triggered after following a certain amount of content. The content in duplicate's description contains too much whitespace to be be followed.

<meta name="og:description" content="
Possible Duplicate:
Which keycode for escape key with jQuery  

How to detect escape key press in IE, Firefox and Chrome?
Below code works in IE and alerts 27, but in firefox it alerts 0

" />

Perhaps omitting the duplicate text and whitespace here can help.

Duplicates lack alternate xml markup

<link rel="alternate" type="application/atom+xml" title="Feed for question &#39;Which keycode for escape key with jQuery&#39;" href="/feeds/question/1160008">

The tag exists in the "original" but not in any of the duplicates. I am not sure if this has any affect. Perhaps including the alternate xml will assist in text showing up in the search.

Worst case scenario

There is no way to prevent that part from being indexed as the first content because it is the most visible (least nested) heading element followed by a paragraph element on the page. Perhaps the title text can be repeated there in place of "This question".

Get ESC keypress event on HTML/JavaScript? has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Just my 2¢

  • it should be possible to hide it from Google by making it inserted by Javascript. SO doesn't support no-javascript users anyways Nov 26, 2013 at 15:59
  • @JanDvorak - While looking at some of these issues I turned off javascript to inspect the page thinking perhaps some of the content was being changed. The site actually runs pretty well without javascript with all things considered. It does warn you that it runs better with it enabled. I wouldn't go so far as to say that SO doesn't support them. As for inserting it with javascript or having it in a noscript tag, I am not sure how that would affect the search. Do you have any articles describing how Google views this behavior?
    – Travis J
    Nov 26, 2013 at 16:04

You must log in to answer this question.

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