var Me = {
  
  // Borrowed from http://henrik.nyh.se
  explainGlyphs: function() {
    var glyphs = {
      "␣": "Space",
      "↩": "Return",
      "⌅": "Enter",
      "⇥": "Tab",
      "⇤": "Backtab",
      "⌫": "Backspace",
      "⌦": "Forward Delete",
      "⌘": "Command",
      "⌥": "Option",
      "^": "Control",
      "⌃": "Control",
      "⇧": "Shift",
      "⇪": "Caps Lock",
      "←": "Left Arrow",
      "→": "Right Arrow",
      "↑": "Up Arrow",
      "↓": "Down Arrow",
      "↖": "Home",
      "↘": "End",
      "⇞": "Page Up",
      "⇟": "Page Down",
      "⎋": "Escape",
      "⏏": "Eject"
    };

    function glyphsToNames(text) {
      return text.split('').map(function(x) { return (glyphs[x] || x) }).join(" ");
    }
    $('.kb').each(function() {
      var text = $(this).text();
      this.title = "Key"+(text.length>1 ? "s" : "")+": " + glyphsToNames(text);
    });
  },
  removeWidows: function(){
    $("h1").each(function() {
      //alert($(this).text())
      $(this).html($(this).text().replace(/ (\w+)$/,' $1'));
    });
  },
  init: function(){
    this.explainGlyphs();
    this.removeWidows();
  }
};
$(function() { Me.init() });
