title: javascript jQuery get object key
body: <p>I have the following code:</p>
  
  <pre><code>!function($){
  
      $.keys = {
          backspace: 8,
          tab: 9,
          enter: 13,
          escape: 27,
          space: 32,
          pageUp: 33,
          pageDown: 34,
          end: 35,
          home: 36,
          left: 37,
          up: 38,
          right: 39,
          down: 40,
          delete: 46,
          numpadEnter: 108,
          comma: 188
      };
  
  }(window.jQuery);
  </code></pre>
  
  <p>And I want to build a function that returns a string of a key code for example:</p>
  
  <pre><code>$.keys.toString = function(key){
    switch(key){
      case $.keys.backspace:
        return 'backspace';
    }
  };
  </code></pre>
  
  <p>The list would ofcourse be bigger, and support all the keys of the $.keys object. But is there a possibility that the $.keys.toString function actually uses the $.keys array to convert the int to string, so I don't have to make a switch statement.</p>
  
  <p>Something like getKeyFromObjectValue?</p>
  
  <p>Thanks for help :)</p>